|
2 | 2 | # Licensed under the MIT License.
|
3 | 3 |
|
4 | 4 | Describe 'metadata tests' {
|
| 5 | + It 'resource can provide high-level metadata for <operation>' -TestCases @( |
| 6 | + @{ operation = 'get' } |
| 7 | + @{ operation = 'set' } |
| 8 | + @{ operation = 'test' } |
| 9 | + ) { |
| 10 | + param($operation) |
| 11 | + |
| 12 | + $configYaml = @' |
| 13 | + $schema: https://aka.ms/dsc/schemas/v3/bundled/config/document.json |
| 14 | + resources: |
| 15 | + - name: test |
| 16 | + type: Test/Metadata |
| 17 | + metadata: |
| 18 | + hello: world |
| 19 | + myNumber: 42 |
| 20 | + properties: |
| 21 | +'@ |
| 22 | + |
| 23 | + $out = dsc config $operation -i $configYaml 2>$TestDrive/error.log | ConvertFrom-Json |
| 24 | + $LASTEXITCODE | Should -Be 0 |
| 25 | + $out.results.count | Should -Be 1 |
| 26 | + $out.results[0].metadata.hello | Should -BeExactly 'world' |
| 27 | + $out.results[0].metadata.myNumber | Should -Be 42 |
| 28 | + } |
| 29 | + |
| 30 | + It 'resource can provide high-level metadata for export' { |
| 31 | + $configYaml = @' |
| 32 | + $schema: https://aka.ms/dsc/schemas/v3/bundled/config/document.json |
| 33 | + resources: |
| 34 | + - name: test |
| 35 | + type: Test/Metadata |
| 36 | + metadata: |
| 37 | + hello: There |
| 38 | + myNumber: 16 |
| 39 | + properties: |
| 40 | +'@ |
| 41 | + $out = dsc config export -i $configYaml 2>$TestDrive/error.log | ConvertFrom-Json |
| 42 | + $LASTEXITCODE | Should -Be 0 |
| 43 | + $out.resources.count | Should -Be 3 |
| 44 | + $out.resources[0].metadata.hello | Should -BeExactly 'There' |
| 45 | + $out.resources[0].metadata.myNumber | Should -Be 16 |
| 46 | + $out.resources[0].name | Should -BeExactly 'Metadata example 1' |
| 47 | + $out.resources[1].metadata.hello | Should -BeExactly 'There' |
| 48 | + $out.resources[1].metadata.myNumber | Should -Be 16 |
| 49 | + $out.resources[1].name | Should -BeExactly 'Metadata example 2' |
| 50 | + $out.resources[2].metadata.hello | Should -BeExactly 'There' |
| 51 | + $out.resources[2].metadata.myNumber | Should -Be 16 |
| 52 | + $out.resources[2].name | Should -BeExactly 'Metadata example 3' |
| 53 | + } |
| 54 | + |
5 | 55 | It 'resource can provide metadata for <operation>' -TestCases @(
|
6 | 56 | @{ operation = 'get' }
|
7 | 57 | @{ operation = 'set' }
|
|
0 commit comments