-
-
Notifications
You must be signed in to change notification settings - Fork 26
Expand file tree
/
Copy pathInitialize-PSBuild.tests.ps1
More file actions
57 lines (46 loc) · 2.06 KB
/
Initialize-PSBuild.tests.ps1
File metadata and controls
57 lines (46 loc) · 2.06 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
Describe 'Initialize-PSBuild' {
BeforeAll {
Import-Module "$PSScriptRoot/../PowerShellBuild/PowerShellBuild.psd1" -Force
}
BeforeEach {
$script:capturedBuildOutput = $null
Mock -CommandName Set-BuildEnvironment -MockWith {
param($BuildOutput)
$script:capturedBuildOutput = $BuildOutput
}
$env:BHProjectPath = '/repo/project'
$env:BHProjectName = 'DemoModule'
$script:baseEnvironment = @{
Build = @{
OutDir = 'out'
}
General = @{
ModuleVersion = '1.2.3'
}
}
}
It 'sets ModuleOutDir under BHProjectPath when OutDir is relative' {
$envCopy = $script:baseEnvironment.PSObject.Copy()
Initialize-PSBuild -BuildEnvironment $script:baseEnvironment
$expected = [IO.Path]::Combine('/repo/project', 'out', 'DemoModule', '1.2.3')
$script:baseEnvironment.Build.ModuleOutDir | Should -Be $expected
$script:capturedBuildOutput | Should -Be $expected
Assert-MockCalled Set-BuildEnvironment -Times 1 -Exactly
}
It 'keeps OutDir-rooted path when OutDir already starts with BHProjectPath (case-insensitive)' {
$script:baseEnvironment.Build.OutDir = '/REPO/PROJECT/out'
Initialize-PSBuild -BuildEnvironment $script:baseEnvironment
$expected = [IO.Path]::Combine('/REPO/PROJECT/out', 'DemoModule', '1.2.3')
$script:baseEnvironment.Build.ModuleOutDir | Should -Be $expected
$script:capturedBuildOutput | Should -Be $expected
Assert-MockCalled Set-BuildEnvironment -Times 1 -Exactly
}
It 'prints BuildHelpers environment section only when UseBuildHelpers is present' {
Mock -CommandName Get-Item -MockWith { @() }
Mock -CommandName Write-Host
Initialize-PSBuild -BuildEnvironment $script:baseEnvironment
Assert-MockCalled Write-Host -Times 2 -Exactly
Initialize-PSBuild -BuildEnvironment $script:baseEnvironment -UseBuildHelpers
Assert-MockCalled Write-Host -Times 5
}
}