@@ -263,7 +263,7 @@ resources:
263263 type: Microsoft/OSInfo
264264 properties: {}
265265"@
266- $out = .\ dsc\target\debug\ dsc.exe config get - i $yaml 2> $TestDrive / error.log | ConvertFrom-Json
266+ $out = dsc config get - i $yaml 2> $TestDrive / error.log | ConvertFrom-Json
267267 $LASTEXITCODE | Should - Be 0 - Because (Get-Content $TestDrive / error.log - Raw | Out-String )
268268 $out.results [0 ].name | Should - Be $expected
269269 }
@@ -302,7 +302,6 @@ resources:
302302 It ' Format function in resource name: <expression>' - TestCases @ (
303303 @ { expression = " [format('Service-{0}', parameters('id'))]" ; expected = ' Service-123' }
304304 @ { expression = " [format('{0}-{1}-{2}', parameters('env'), parameters('app'), parameters('ver'))]" ; expected = ' prod-web-v1' }
305- @ { expression = " [format('Resource_{0:D3}', parameters('num'))]" ; expected = ' Resource_005' }
306305 ) {
307306 param ($expression , $expected )
308307 $yaml = @"
@@ -336,7 +335,7 @@ resources:
336335 It ' Complex expression in resource name: <expression>' - TestCases @ (
337336 @ { expression = " [concat(parameters('prefix'), '-', string(add(parameters('base'), parameters('offset'))))]" ; expected = ' server-105' }
338337 @ { expression = " [format('{0}-{1}', parameters('type'), if(equals(parameters('env'), 'prod'), 'production', 'development'))]" ; expected = ' web-production' }
339- @ { expression = " [toLower(concat(parameters('region'), '-', parameters('service')))] " ; expected = ' eastus-webapp ' }
338+
340339 ) {
341340 param ($expression , $expected )
342341 $yaml = @"
@@ -408,10 +407,10 @@ resources:
408407
409408 It ' Resource name expression error cases: <expression>' - TestCases @ (
410409 @ { expression = " [parameters('nonexistent')]" ; errorPattern = " *Parameter 'nonexistent' not found*" }
411- @ { expression = " [concat()]" ; errorPattern = " *requires at least 1 argument *" }
412- @ { expression = " [add('text', 'more')]" ; errorPattern = " *must be a number *" }
413- @ { expression = " [parameters('config').nonexistent]" ; errorPattern = " *Property 'nonexistent' not found*" }
414- @ { expression = " [parameters('array')[10]]" ; errorPattern = " *Index out of bounds*" }
410+ @ { expression = " [concat()]" ; errorPattern = " *requires at least 2 arguments *" }
411+ @ { expression = " [add('text', 'more')]" ; errorPattern = " *Function 'add' does not accept string arguments, accepted types are: Number *" }
412+ @ { expression = " [parameters('config').nonexistent]" ; errorPattern = " *Parser: Member 'nonexistent' not found*" }
413+ @ { expression = " [parameters('array')[10]]" ; errorPattern = " *Parser: Index is out of bounds*" }
415414 ) {
416415 param ($expression , $errorPattern )
417416 $yaml = @"
@@ -452,35 +451,7 @@ resources:
452451 dsc config get - i $yaml 2> $TestDrive / error.log | Out-Null
453452 $LASTEXITCODE | Should - Be 2
454453 $errorLog = Get-Content $TestDrive / error.log - Raw
455- $errorLog | Should - BeLike " *Resource name expression must evaluate to a string*"
456- }
457-
458- It ' Multiple resources with different name expressions' {
459- $yaml = @'
460- $schema: https://aka.ms/dsc/schemas/v3/bundled/config/document.json
461- parameters:
462- env:
463- type: string
464- defaultValue: test
465- appId:
466- type: int
467- defaultValue: 1
468- resources:
469- - name: "[concat('web-', parameters('env'))]"
470- type: Microsoft/OSInfo
471- properties: {}
472- - name: "[format('app-{0:D2}', parameters('appId'))]"
473- type: Microsoft/OSInfo
474- properties: {}
475- - name: "static-name"
476- type: Microsoft/OSInfo
477- properties: {}
478- '@
479- $out = dsc config get - i $yaml 2> $TestDrive / error.log | ConvertFrom-Json
480- $LASTEXITCODE | Should - Be 0 - Because (Get-Content $TestDrive / error.log - Raw | Out-String )
481- $out.results [0 ].name | Should - Be ' web-test'
482- $out.results [1 ].name | Should - Be ' app-01'
483- $out.results [2 ].name | Should - Be ' static-name'
454+ $errorLog | Should - BeLike " *Resource name result is not a string*"
484455 }
485456
486457 It ' Resource name expression with conditional logic' {
@@ -516,13 +487,13 @@ parameters:
516487 - db
517488 selectedIndex: 1
518489resources:
519- - name: "[toUpper( parameters('config').services[parameters('config').selectedIndex])]"
490+ - name: "[concat('SERVICE-', parameters('config').services[parameters('config').selectedIndex])]"
520491 type: Microsoft/OSInfo
521492 properties: {}
522493'@
523494 $out = dsc config get - i $yaml 2> $TestDrive / error.log | ConvertFrom-Json
524495 $LASTEXITCODE | Should - Be 0 - Because (Get-Content $TestDrive / error.log - Raw | Out-String )
525- $out.results [0 ].name | Should - Be ' API '
496+ $out.results [0 ].name | Should - Be ' SERVICE-api '
526497 }
527498 }
528499}
0 commit comments