Skip to content

Commit 6bdf559

Browse files
committed
Not working with index
1 parent 4cca197 commit 6bdf559

File tree

1 file changed

+23
-35
lines changed

1 file changed

+23
-35
lines changed

dsc/tests/dsc_extension_discover.tests.ps1

Lines changed: 23 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -23,42 +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 5 -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.DSC.Extension/PowerShell'
33-
$out[1].version | Should -Be '0.1.0'
34-
$out[1].capabilities | Should -BeExactly @('import')
35-
$out[1].manifest | Should -Not -BeNullOrEmpty
36-
$out[2].type | Should -Be 'Microsoft.DSC.Extension/WindowsPowerShell'
37-
$out[2].version | Should -Be '0.1.0'
38-
$out[2].capabilities | Should -BeExactly @('import')
39-
$out[2].manifest | Should -Not -BeNullOrEmpty
40-
$out[3].type | Should -Be 'Microsoft.Windows.Appx/Discover'
41-
$out[3].version | Should -Be '0.1.0'
42-
$out[3].capabilities | Should -BeExactly @('discover')
43-
$out[3].manifest | Should -Not -BeNullOrEmpty
44-
$out[4].type | Should -BeExactly 'Test/Discover'
45-
$out[4].version | Should -BeExactly '0.1.0'
46-
$out[4].capabilities | Should -BeExactly @('discover')
47-
$out[4].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.Extension/PowerShell'; version = '0.1.0'; capabilities = @('import') }
30+
@{ type = 'Microsoft.DSC.Extension/WindowsPowerShell'; version = '0.1.0'; capabilities = @('import') }
31+
@{ type = 'Microsoft.Windows.Appx/Discover'; version = '0.1.0'; capabilities = @('discover') }
32+
@{ type = 'Test/Discover'; version = '0.1.0'; capabilities = @('discover') }
33+
)
4834
} else {
49-
$out.Count | Should -Be 3 -Because ($out | Out-String)
50-
$out[0].type | Should -Be 'Microsoft.DSC.Extension/Bicep'
51-
$out[0].version | Should -Be '0.1.0'
52-
$out[0].capabilities | Should -BeExactly @('import')
53-
$out[0].manifest | Should -Not -BeNullOrEmpty
54-
$out[1].type | Should -Be 'Microsoft.DSC.Extension/PowerShell'
55-
$out[1].version | Should -Be '0.1.0'
56-
$out[1].capabilities | Should -BeExactly @('import')
57-
$out[1].manifest | Should -Not -BeNullOrEmpty
58-
$out[2].type | Should -BeExactly 'Test/Discover'
59-
$out[2].version | Should -BeExactly '0.1.0'
60-
$out[2].capabilities | Should -BeExactly @('discover')
61-
$out[2].manifest | Should -Not -BeNullOrEmpty
35+
@(
36+
@{ type = 'Microsoft.DSC.Extension/Bicep'; version = '0.1.0'; capabilities = @('import') }
37+
@{ type = 'Microsoft.DSC.Extension/PowerShell'; version = '0.1.0'; capabilities = @('import') }
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
6250
}
6351
}
6452

0 commit comments

Comments
 (0)