forked from PowerShell/PowerShell
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRequires.Tests.ps1
More file actions
28 lines (25 loc) · 1.28 KB
/
Copy pathRequires.Tests.ps1
File metadata and controls
28 lines (25 loc) · 1.28 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
Describe "Requires tests" -Tags "CI" {
Context "Parser error" {
$testcases = @(
@{command = "#requiresappID`r`n$foo = 1; $foo" ; testname = "appId with newline"}
@{command = "#requires -version A `r`n$foo = 1; $foo" ; testname = "version as character"}
@{command = "#requires -version 2b `r`n$foo = 1; $foo" ; testname = "alphanumeric version"}
@{command = "#requires -version 1. `r`n$foo = 1; $foo" ; testname = "version with dot"}
@{command = "#requires -version '' `r`n$foo = 1; $foo" ; testname = "empty version"}
@{command = "#requires -version 1.0. `r`n$foo = 1; $foo" ; testname = "version with two dots"}
@{command = "#requires -version 1.A `r`n$foo = 1; $foo" ; testname = "alphanumeric version with dots"}
)
It "throws ParserException - <testname>" -TestCases $testcases {
param($command)
try
{
[scriptblock]::Create($command)
throw "'$command' should have thrown ParserError"
}
catch
{
$_.FullyQualifiedErrorId | Should Be "ParseException"
}
}
}
}