-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathUpdate-DevSetup.Tests.ps1
More file actions
88 lines (73 loc) · 3.09 KB
/
Update-DevSetup.Tests.ps1
File metadata and controls
88 lines (73 loc) · 3.09 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
77
78
79
80
81
82
83
84
85
86
87
88
BeforeAll {
# Source the function under test
. $PSScriptRoot\Update-DevSetup.ps1
. $PSScriptRoot\..\Updater\Start-DevSetupSelfUpdate.ps1
Mock Start-DevSetupSelfUpdate { }
}
Describe "Update-DevSetup" {
Context "When Main parameter is specified" {
It "Should call Start-DevSetupSelfUpdate with Main parameter" {
Update-DevSetup -Main
Assert-MockCalled Start-DevSetupSelfUpdate -Exactly 1 -Scope It -ParameterFilter { $Main -eq $true }
}
}
Context "When Develop parameter is specified" {
It "Should call Start-DevSetupSelfUpdate with Develop parameter" {
Update-DevSetup -Develop
Assert-MockCalled Start-DevSetupSelfUpdate -Exactly 1 -Scope It -ParameterFilter { $Develop -eq $true }
}
}
Context "When Version parameter is specified" {
It "Should call Start-DevSetupSelfUpdate with Version parameter" {
Update-DevSetup -Version "1.0.0"
Assert-MockCalled Start-DevSetupSelfUpdate -Exactly 1 -Scope It -ParameterFilter { $Version -eq "1.0.0" }
}
}
Context "When no parameters are specified (default)" {
It "Should call Start-DevSetupSelfUpdate without parameters (letting it use its own defaults)" {
Update-DevSetup
Assert-MockCalled Start-DevSetupSelfUpdate -Exactly 1 -Scope It -ParameterFilter { $PSBoundParameters.Count -eq 0 }
}
}
Context "Parameter set validation" {
It "Should allow Main parameter alone" {
{ Update-DevSetup -Main } | Should -Not -Throw
}
It "Should allow Develop parameter alone" {
{ Update-DevSetup -Develop } | Should -Not -Throw
}
It "Should allow Version parameter alone" {
{ Update-DevSetup -Version "2.0.0" } | Should -Not -Throw
}
It "Should not allow Main and Develop together" {
{ Update-DevSetup -Main -Develop } | Should -Throw
}
It "Should not allow Main and Version together" {
{ Update-DevSetup -Main -Version "1.0.0" } | Should -Throw
}
It "Should not allow Develop and Version together" {
{ Update-DevSetup -Develop -Version "1.0.0" } | Should -Throw
}
}
Context "PSBoundParameters forwarding" {
It "Should forward all parameters using splatting" {
Mock Start-DevSetupSelfUpdate { } -ParameterFilter { $PSBoundParameters.Count -gt 0 }
Update-DevSetup -Version "test"
Assert-MockCalled Start-DevSetupSelfUpdate -Exactly 1 -Scope It
}
}
Context "Cross-platform compatibility" {
It "Should work on Windows" {
Update-DevSetup -Main
Assert-MockCalled Start-DevSetupSelfUpdate -Exactly 1 -Scope It
}
It "Should work on Linux" {
Update-DevSetup -Develop
Assert-MockCalled Start-DevSetupSelfUpdate -Exactly 1 -Scope It
}
It "Should work on macOS" {
Update-DevSetup -Version "1.0.0"
Assert-MockCalled Start-DevSetupSelfUpdate -Exactly 1 -Scope It
}
}
}