-
-
Notifications
You must be signed in to change notification settings - Fork 26
Expand file tree
/
Copy pathBuild-PSBuildModule.tests.ps1
More file actions
76 lines (66 loc) · 2.57 KB
/
Build-PSBuildModule.tests.ps1
File metadata and controls
76 lines (66 loc) · 2.57 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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
Describe 'Build-PSBuildModule' {
BeforeAll {
. "$PSScriptRoot/../PowerShellBuild/Public/Build-PSBuildModule.ps1"
}
BeforeEach {
$script:LocalizedData = @{
AddingFileToPsm1 = 'Adding file {0}'
}
}
It 'copies README into culture about-help file when ReadMePath is provided' {
Mock Test-Path {
if ($LiteralPath -eq '/tmp/out') { return $false }
if ($Path -eq '/tmp/out/en-US' -and $PathType -eq 'Container') { return $false }
return $false
}
Mock New-Item {}
Mock Get-ChildItem { @() }
Mock Copy-Item {}
Mock Update-Metadata {}
Build-PSBuildModule \
-Path '/tmp/src' \
-DestinationPath '/tmp/out' \
-ModuleName 'TestModule' \
-ReadMePath '/tmp/src/README.md' \
-Culture 'en-US'
Should -Invoke New-Item -Times 1 -ParameterFilter { $Path -eq '/tmp/out' -and $ItemType -eq 'Directory' }
Should -Invoke New-Item -Times 1 -ParameterFilter { $Path -eq '/tmp/out/en-US' -and $Type -eq 'Directory' -and $Force }
Should -Invoke Copy-Item -Times 1 -ParameterFilter {
$LiteralPath -eq '/tmp/src/README.md' -and
$Destination -eq '/tmp/out/en-US/about_TestModule.help.txt' -and
$Force
}
}
It 'updates manifest FunctionsToExport from Public/*.ps1 basenames' {
Mock Test-Path { $true }
Mock Copy-Item {}
Mock Remove-Item {}
Mock Update-Metadata {}
Mock Get-ChildItem {
@()
} -ParameterFilter { $Path -eq '/tmp/src' -and $Include -contains '*.psm1' }
Mock Get-ChildItem {
@(
[pscustomobject]@{ Name = 'skip.tmp'; FullName = '/tmp/out/skip.tmp' }
)
} -ParameterFilter { $Path -eq '/tmp/out' -and $Recurse }
Mock Get-ChildItem {
@(
[pscustomobject]@{ BaseName = 'Get-Foo' },
[pscustomobject]@{ BaseName = 'Set-Bar' }
)
} -ParameterFilter { $Path -eq '/tmp/src/Public/*.ps1' -and $Recurse }
Build-PSBuildModule \
-Path '/tmp/src' \
-DestinationPath '/tmp/out' \
-ModuleName 'TestModule' \
-Exclude @('\\.tmp$')
Should -Invoke Update-Metadata -Times 1 -ParameterFilter {
$Path -eq '/tmp/out/TestModule.psd1' -and
$PropertyName -eq 'FunctionsToExport' -and
$Value.Count -eq 2 -and
$Value[0] -eq 'Get-Foo' -and
$Value[1] -eq 'Set-Bar'
}
}
}