Skip to content

Commit 29d76fb

Browse files
committed
Fix discovery test
1 parent b725f2c commit 29d76fb

File tree

2 files changed

+37
-23
lines changed

2 files changed

+37
-23
lines changed

dsc/tests/dsc_extension_discover.tests.ps1

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -23,30 +23,30 @@ Describe 'Discover extension tests' {
2323
It 'Discover extensions' {
2424
$out = dsc extension list | ConvertFrom-Json
2525
$LASTEXITCODE | Should -Be 0
26-
if ($IsWindows) {
27-
$out.Count | Should -Be 3 -Because ($out | Out-String)
28-
$out[0].type | Should -Be 'Microsoft.DSC.Extension/Bicep'
29-
$out[0].version | Should -Be '0.1.0'
30-
$out[0].capabilities | Should -BeExactly @('import')
31-
$out[0].manifest | Should -Not -BeNullOrEmpty
32-
$out[1].type | Should -Be 'Microsoft.Windows.Appx/Discover'
33-
$out[1].version | Should -Be '0.1.0'
34-
$out[1].capabilities | Should -BeExactly @('discover')
35-
$out[1].manifest | Should -Not -BeNullOrEmpty
36-
$out[2].type | Should -BeExactly 'Test/Discover'
37-
$out[2].version | Should -BeExactly '0.1.0'
38-
$out[2].capabilities | Should -BeExactly @('discover')
39-
$out[2].manifest | Should -Not -BeNullOrEmpty
26+
$expectedExtensions = if ($IsWindows) {
27+
@(
28+
@{ type = 'Microsoft.DSC.Extension/Bicep'; version = '0.1.0'; capabilities = @('import') }
29+
@{ type = 'Microsoft.DSC.Transitional/PSDesiredStateConfiguration'; version = '0.1.0'; capabilities = @('import') }
30+
@{ type = 'Microsoft.Windows.Appx/Discover'; version = '0.1.0'; capabilities = @('discover') }
31+
@{ type = 'Microsoft.PowerShell/SecretManagement'; version = '0.1.0'; capabilities = @('secret') }
32+
@{ type = 'Test/Discover'; version = '0.1.0'; capabilities = @('discover') }
33+
)
4034
} else {
41-
$out.Count | Should -Be 2 -Because ($out | Out-String)
42-
$out[0].type | Should -Be 'Microsoft.DSC.Extension/Bicep'
43-
$out[0].version | Should -Be '0.1.0'
44-
$out[0].capabilities | Should -BeExactly @('import')
45-
$out[0].manifest | Should -Not -BeNullOrEmpty
46-
$out[1].type | Should -BeExactly 'Test/Discover'
47-
$out[1].version | Should -BeExactly '0.1.0'
48-
$out[1].capabilities | Should -BeExactly @('discover')
49-
$out[1].manifest | Should -Not -BeNullOrEmpty
35+
@(
36+
@{ type = 'Microsoft.DSC.Extension/Bicep'; version = '0.1.0'; capabilities = @('import') }
37+
@{ type = 'Microsoft.PowerShell/SecretManagement'; version = '0.1.0'; capabilities = @('secret') }
38+
@{ type = 'Test/Discover'; version = '0.1.0'; capabilities = @('discover') }
39+
)
40+
}
41+
42+
$out.Count | Should -Be $expectedExtensions.Count -Because ($out | Out-String)
43+
44+
foreach ($expected in $expectedExtensions) {
45+
$extension = $out | Where-Object { $_.type -eq $expected.type }
46+
$extension | Should -Not -BeNullOrEmpty -Because "Extension $($expected.type) should exist"
47+
$extension.version | Should -BeExactly $expected.version
48+
$extension.capabilities | Should -BeExactly $expected.capabilities
49+
$extension.manifest | Should -Not -BeNullOrEmpty
5050
}
5151
}
5252

test.ps1

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
configuration MyConfiguration {
2+
Import-DscResource -ModuleName PSDesiredStateConfiguration
3+
Node localhost
4+
{
5+
Environment CreatePathEnvironmentVariable
6+
{
7+
Name = 'TestPathEnvironmentVariable'
8+
Value = 'TestValue'
9+
Ensure = 'Present'
10+
Path = $true
11+
Target = @('Process')
12+
}
13+
}
14+
}

0 commit comments

Comments
 (0)