-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPSCustomObject.Tests.ps1
More file actions
68 lines (59 loc) · 1.99 KB
/
Copy pathPSCustomObject.Tests.ps1
File metadata and controls
68 lines (59 loc) · 1.99 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
#Requires -Modules @{ ModuleName = 'Pester'; ModuleVersion = '6.0.0'; MaximumVersion = '6.*' }
[Diagnostics.CodeAnalysis.SuppressMessageAttribute(
'PSUseDeclaredVarsMoreThanAssignments', '',
Justification = 'Pester grouping syntax: known issue.'
)]
[Diagnostics.CodeAnalysis.SuppressMessageAttribute(
'PSAvoidUsingConvertToSecureStringWithPlainText', '',
Justification = 'Used to create a secure string for testing.'
)]
[Diagnostics.CodeAnalysis.SuppressMessageAttribute(
'PSAvoidUsingWriteHost', '',
Justification = 'Log outputs to GitHub Actions logs.'
)]
[Diagnostics.CodeAnalysis.SuppressMessageAttribute(
'PSAvoidLongLines', '',
Justification = 'Long test descriptions and skip switches'
)]
[CmdletBinding()]
param()
Describe 'PSCustomObject' {
It 'Function: Compare-PSCustomObject' {
$Left = [PSCustomObject]@{
Name = 'Test'
Value = 1
}
$Right = [PSCustomObject]@{
Name = 'Test'
Value = 2
}
LogGroup 'Diff' {
$diff = $Left | Compare-PSCustomObject $Right
Write-Host "$($diff | Format-Table | Out-String)"
}
$diff | Should -HaveCount 2
$diff.Property | Should -BeIn @('Name', 'Value')
$diff.Left | Should -BeIn @('Test', 1)
$diff.Right | Should -BeIn @('Test', 2)
$diff.Changed | Should -Contain $true
}
It 'Function: Compare-PSCustomObject -OnlyChanged' {
$Left = [PSCustomObject]@{
Name = 'Test'
Value = 1
}
$Right = [PSCustomObject]@{
Name = 'Test'
Value = 2
}
LogGroup 'Diff' {
$diff = $Left | Compare-PSCustomObject $Right -OnlyChanged
Write-Host "$($diff | Format-Table | Out-String)"
}
$diff | Should -HaveCount 1
$diff.Property | Should -Be 'Value'
$diff.Left | Should -Be 1
$diff.Right | Should -Be 2
$diff.Changed | Should -Be $true
}
}