@@ -9,27 +9,37 @@ Describe "Build-Module" {
9
9
$parameters [" SourcePath" ].ParameterType | Should - Be ([string ])
10
10
$parameters [" SourcePath" ].Attributes.Where{$_ -is [Parameter ]}.Mandatory | Should - Be $false
11
11
}
12
+ It " throws if the SourcePath doesn't exist" {
13
+ { Build-Module - SourcePath TestDrive:\NoSuchPath } | Should - Throw " Source must point to a valid module"
14
+ }
12
15
13
16
It " has an optional string parameter for the OutputDirectory" {
14
17
$parameters.ContainsKey (" OutputDirectory" ) | Should - Be $true
15
18
$parameters [" OutputDirectory" ].ParameterType | Should - Be ([string ])
16
19
$parameters [" OutputDirectory" ].Attributes.Where{$_ -is [Parameter ]}.Mandatory | Should - Be $false
17
20
}
18
21
19
- It " has an optional parameter for setting the Version" {
22
+ It " has an optional parameter for setting the Version" {
20
23
$parameters.ContainsKey (" Version" ) | Should - Be $true
21
24
$parameters [" Version" ].ParameterType | Should - Be ([version ])
22
25
$parameters [" Version" ].ParameterSets.Keys | Should -Not - Be " __AllParameterSets"
23
26
}
24
27
25
- It " has an optional parameter for setting the Encoding" {
28
+ It " has an optional parameter for setting the Encoding" {
26
29
$parameters.ContainsKey (" Encoding" ) | Should - Be $true
27
30
# Note that in PS Core, we can't use encoding types for parameters
28
31
$parameters [" Encoding" ].ParameterType | Should - Be ([string ])
29
32
$parameters [" Encoding" ].Attributes.Where{$_ -is [Parameter ]}.Mandatory | Should - Be $false
30
33
}
31
34
32
- It " has an optional string parameter for a Prefix" {
35
+ It " Warns if you set the encoding to anything but UTF8" {
36
+ $warns = @ ()
37
+ # Note: Using WarningAction Stop just to avoid testing anything else here ;)
38
+ try { Build-Module - Encoding ASCII - WarningAction Stop - WarningVariable + warns } catch {}
39
+ $warns.Message | Should -Match " recommend you build your script modules with UTF8 encoding"
40
+ }
41
+
42
+ It " has an optional string parameter for a Prefix" {
33
43
$parameters.ContainsKey (" Prefix" ) | Should - Be $true
34
44
$parameters [" Prefix" ].ParameterType | Should - Be ([string ])
35
45
$parameters [" Prefix" ].Attributes.Where{$_ -is [Parameter ]}.Mandatory | Should - Be $false
0 commit comments