Skip to content

Commit 30816bb

Browse files
committed
Add Pester test for ARMv2
1 parent 7984ca1 commit 30816bb

File tree

2 files changed

+68
-2
lines changed

2 files changed

+68
-2
lines changed

dsc/tests/dsc_armv2.tests.ps1

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
# Copyright (c) Microsoft Corporation.
2+
# Licensed under the MIT License.
3+
4+
Describe 'ARM Language 2.0 tests' {
5+
It 'config with ARM Language 2.0 format works' {
6+
<#
7+
This JSON config built from the following Bicep code using the
8+
desiredStateConfiguration and moduleExtensionConfigs experimental features:
9+
10+
extension dsc
11+
targetScope = 'desiredStateConfiguration'
12+
13+
resource echoResource 'Microsoft.DSC.Debug/Echo@1.0.0' = {
14+
output: 'Hello World'
15+
}
16+
#>
17+
$configJson = @'
18+
{
19+
"$schema": "https://aka.ms/dsc/schemas/v3/bundled/config/document.json",
20+
"languageVersion": "2.2-experimental",
21+
"contentVersion": "1.0.0.0",
22+
"metadata": {
23+
"_EXPERIMENTAL_WARNING": "This template uses ARM features that are experimental. Experimental features should be enabled for testing purposes only, as there are no guarantees about the quality or stability of these features. Do not enable these settings for any production usage, or your production environment may be subject to breaking.",
24+
"_EXPERIMENTAL_FEATURES_ENABLED": [
25+
"Enable defining extension configs for modules"
26+
],
27+
"_generator": {
28+
"name": "bicep",
29+
"version": "0.38.33.27573",
30+
"templateHash": "5233252217641859406"
31+
}
32+
},
33+
"extensions": {
34+
"dsc": {
35+
"name": "DesiredStateConfiguration",
36+
"version": "0.1.0"
37+
}
38+
},
39+
"resources": {
40+
"echoResource": {
41+
"extension": "dsc",
42+
"type": "Microsoft.DSC.Debug/Echo",
43+
"apiVersion": "1.0.0",
44+
"properties": {
45+
"output": "Hello World"
46+
}
47+
}
48+
}
49+
}
50+
'@
51+
$out = dsc config get -i $configJson | ConvertFrom-Json -Depth 10
52+
$LASTEXITCODE | Should -Be 0
53+
$out.results | Should -HaveCount 1
54+
$out.results[0].type | Should -Be 'Microsoft.DSC.Debug/Echo'
55+
$out.results[0].result.actualState.output | Should -Be 'Hello World'
56+
}
57+
}

lib/dsc-lib/src/configure/config_doc.rs

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -204,8 +204,17 @@ where
204204
resources.into_iter()
205205
.map(|(name, resource)| {
206206
let mut resource: Resource = serde_json::from_value(resource).map_err(serde::de::Error::custom)?;
207-
// TODO: Decide what to do if resource.name is already set.
208-
resource.name = name;
207+
// Note that this is setting the symbolic name as the
208+
// resource's name property only if that isn't already set.
209+
// In the general use case from Bicep, it won't be, but
210+
// we're unsure of the implications in other use cases.
211+
//
212+
// TODO: We will need to update the 'dependsOn' logic to
213+
// accept both the symbolic name as mapped here in addition
214+
// to `resourceId()`.
215+
if resource.name.is_empty() {
216+
resource.name = name;
217+
}
209218
Ok(resource)
210219
})
211220
.collect()

0 commit comments

Comments
 (0)