@@ -35,20 +35,20 @@ InModuleScope 'ALZ' {
3535 [Parameter (Mandatory = $true )]
3636 [string ]$withValue
3737 )
38- $config = [pscustomobject ]@ {
39- Nested = [pscustomobject ]@ {
40- Type = " Computed"
41- Description = " A Test Value"
42- Value = $withValue
43- Targets = @ (
44- [pscustomobject ]@ {
45- Name = $configTarget
46- Destination = " Parameters"
47- })
48- }
38+ $config = [pscustomobject ]@ {
39+ Nested = [pscustomobject ]@ {
40+ Type = " Computed"
41+ Description = " A Test Value"
42+ Value = $withValue
43+ Targets = @ (
44+ [pscustomobject ]@ {
45+ Name = $configTarget
46+ Destination = " Parameters"
47+ })
4948 }
49+ }
5050
51- return $config
51+ return $config
5252 }
5353
5454 function Format-ExpectedResult {
@@ -69,7 +69,7 @@ InModuleScope 'ALZ' {
6969 Context ' Edit-ALZConfigurationFilesInPlace should replace the parameters correctly' {
7070
7171 It ' Should replace array values correctly (JSON Object) - first' {
72- $config = Initialize-TestConfiguration - configTarget " parValue.value.[0]" - withValue " value"
72+ $config = Initialize-TestConfiguration - configTarget " parValue.value.[0]" - withValue " value"
7373
7474 $fileContent = ' {
7575 "parameters": {
@@ -99,15 +99,15 @@ InModuleScope 'ALZ' {
9999
100100 $expectedContent = Format-ExpectedResult - expectedJson $expectedContent
101101
102- Edit-ALZConfigurationFilesInPlace - alzEnvironmentDestination ' .' - configuration $config
102+ Edit-ALZConfigurationFilesInPlace - alzEnvironmentDestination ' .' - configuration $config
103103
104104 Should - Invoke - CommandName Out-File `
105105 - ParameterFilter { $FilePath -eq $testFile1Name -and $InputObject -eq $expectedContent } `
106106 - Scope It
107107 }
108108
109109 It ' Should replace array an entire array correctly (JSON Object)' {
110- $config = Initialize-TestConfiguration - configTarget " parValue.value.[1]" - withValue " value"
110+ $config = Initialize-TestConfiguration - configTarget " parValue.value.[1]" - withValue " value"
111111
112112 $fileContent = ' {
113113 "parameters": {
@@ -137,7 +137,7 @@ InModuleScope 'ALZ' {
137137
138138 $expectedContent = Format-ExpectedResult - expectedJson $expectedContent
139139
140- Edit-ALZConfigurationFilesInPlace - alzEnvironmentDestination ' .' - configuration $config
140+ Edit-ALZConfigurationFilesInPlace - alzEnvironmentDestination ' .' - configuration $config
141141
142142 Should - Invoke - CommandName Out-File `
143143 - ParameterFilter { $FilePath -eq $testFile1Name -and $InputObject -eq $expectedContent } `
@@ -147,7 +147,7 @@ InModuleScope 'ALZ' {
147147 It ' Should replace array values correctly (JSON Object) - second' {
148148
149149 $config = [pscustomobject ]@ {
150- Nested = [pscustomobject ]@ {
150+ Nested = [pscustomobject ]@ {
151151 Type = " Computed"
152152 Description = " A Test Value"
153153 Value = @ (
@@ -185,15 +185,15 @@ InModuleScope 'ALZ' {
185185
186186 $expectedContent = Format-ExpectedResult - expectedJson $expectedContent
187187
188- Edit-ALZConfigurationFilesInPlace - alzEnvironmentDestination ' .' - configuration $config
188+ Edit-ALZConfigurationFilesInPlace - alzEnvironmentDestination ' .' - configuration $config
189189
190190 Should - Invoke - CommandName Out-File `
191191 - ParameterFilter { $FilePath -eq $testFile1Name -and $InputObject -eq $expectedContent } `
192192 - Scope It
193193 }
194194
195195 It ' Should not write to files that havent been changed.' {
196- $config = Initialize-TestConfiguration - configTarget " DoesnotExist.value" - withValue " value"
196+ $config = Initialize-TestConfiguration - configTarget " DoesnotExist.value" - withValue " value"
197197
198198 $fileContent = ' {
199199 "parameters": {
@@ -207,15 +207,15 @@ InModuleScope 'ALZ' {
207207 $fileContent
208208 }
209209
210- Edit-ALZConfigurationFilesInPlace - alzEnvironmentDestination ' .' - configuration $config
210+ Edit-ALZConfigurationFilesInPlace - alzEnvironmentDestination ' .' - configuration $config
211211
212212 Should - Invoke - CommandName Out-File `
213213 - Scope It `
214214 - Times 0 - Exactly
215215 }
216216
217217 It ' Should replace simple values correctly (Bicep Object)' {
218- $config = Initialize-TestConfiguration - configTarget " parValue.value" - withValue " value"
218+ $config = Initialize-TestConfiguration - configTarget " parValue.value" - withValue " value"
219219
220220 $fileContent = ' {
221221 "parameters": {
@@ -239,15 +239,15 @@ InModuleScope 'ALZ' {
239239
240240 $expectedContent = Format-ExpectedResult - expectedJson $expectedContent
241241
242- Edit-ALZConfigurationFilesInPlace - alzEnvironmentDestination ' .' - configuration $config
242+ Edit-ALZConfigurationFilesInPlace - alzEnvironmentDestination ' .' - configuration $config
243243
244244 Should - Invoke - CommandName Out-File `
245245 - ParameterFilter { $FilePath -eq $testFile1Name -and $InputObject -eq $expectedContent } `
246246 - Scope It
247247 }
248248
249249 It " Should replace 'Parameter' destinations to nested array objects correctly" {
250- $config = Initialize-TestConfiguration - configTarget " parNested.value.[0].parChildValue.value" - withValue " nested"
250+ $config = Initialize-TestConfiguration - configTarget " parNested.value.[0].parChildValue.value" - withValue " nested"
251251
252252 $fileContent = ' {
253253 "parameters": {
@@ -279,15 +279,15 @@ InModuleScope 'ALZ' {
279279
280280 $expectedContent = Format-ExpectedResult - expectedJson $expectedContent
281281
282- Edit-ALZConfigurationFilesInPlace - alzEnvironmentDestination ' .' - configuration $config
282+ Edit-ALZConfigurationFilesInPlace - alzEnvironmentDestination ' .' - configuration $config
283283
284284 Should - Invoke - CommandName Out-File `
285285 - ParameterFilter { $FilePath -eq $testFile1Name -and $InputObject -eq $expectedContent } `
286286 - Scope It
287287 }
288288
289289 It ' Should replace nested values correctly (Plain JSON Object)' {
290- $config = Initialize-TestConfiguration - configTarget " parNested.value.parChildValue" - withValue " nested"
290+ $config = Initialize-TestConfiguration - configTarget " parNested.value.parChildValue" - withValue " nested"
291291
292292 $fileContent = ' {
293293 "parameters": {
@@ -315,15 +315,15 @@ InModuleScope 'ALZ' {
315315
316316 $expectedContent = Format-ExpectedResult - expectedJson $expectedContent
317317
318- Edit-ALZConfigurationFilesInPlace - alzEnvironmentDestination ' .' - configuration $config
318+ Edit-ALZConfigurationFilesInPlace - alzEnvironmentDestination ' .' - configuration $config
319319
320320 Should - Invoke - CommandName Out-File `
321321 - ParameterFilter { $FilePath -eq $testFile1Name -and $InputObject -eq $expectedContent } `
322322 - Scope It
323323 }
324324
325325 It ' Should replace nested values correctly (Bicep Object)' {
326- $config = Initialize-TestConfiguration - configTarget " parNested.value.parChildValue.value" - withValue " nested"
326+ $config = Initialize-TestConfiguration - configTarget " parNested.value.parChildValue.value" - withValue " nested"
327327
328328 $fileContent = ' {
329329 "parameters": {
@@ -355,7 +355,7 @@ InModuleScope 'ALZ' {
355355
356356 $expectedContent = Format-ExpectedResult - expectedJson $expectedContent
357357
358- Edit-ALZConfigurationFilesInPlace - alzEnvironmentDestination ' .' - configuration $config
358+ Edit-ALZConfigurationFilesInPlace - alzEnvironmentDestination ' .' - configuration $config
359359
360360 Should - Invoke - CommandName Out-File `
361361 - ParameterFilter { $FilePath -eq $testFile1Name -and $InputObject -eq $expectedContent } `
@@ -378,16 +378,6 @@ InModuleScope 'ALZ' {
378378 Value = " test"
379379 DefaultValue = " alz"
380380 }
381- Suffix = [pscustomobject ]@ {
382- Description = " The suffix that will be added to all resources created by this deployment."
383- Targets = @ (
384- [pscustomobject ]@ {
385- Name = " parTopLevelManagementGroupSuffix.value"
386- Destination = " Parameters"
387- })
388- Value = " bla"
389- DefaultValue = " "
390- }
391381 Location = [pscustomobject ]@ {
392382 Description = " Deployment location."
393383 Targets = @ (
@@ -434,9 +424,6 @@ InModuleScope 'ALZ' {
434424 }'
435425 $secondFileContent = ' {
436426 "parameters": {
437- "parTopLevelManagementGroupSuffix": {
438- "value": ""
439- },
440427 "parLocation": {
441428 "value": ""
442429 }
@@ -460,7 +447,7 @@ InModuleScope 'ALZ' {
460447 $secondFileContent
461448 }
462449
463- Edit-ALZConfigurationFilesInPlace - alzEnvironmentDestination ' .' - configuration $defaultConfig
450+ Edit-ALZConfigurationFilesInPlace - alzEnvironmentDestination ' .' - configuration $defaultConfig
464451
465452 Should - Invoke - CommandName Out-File - Scope It - Times 2
466453
@@ -475,7 +462,6 @@ InModuleScope 'ALZ' {
475462 Should - Invoke - CommandName Out-File - ParameterFilter { $FilePath -eq " test1.parameters.json" -and $InputObject -eq $contentStringAfterParsing } - Scope It
476463
477464 $contentAfterParsing = ConvertFrom-Json - InputObject $secondFileContent - AsHashtable
478- $contentAfterParsing.parameters.parTopLevelManagementGroupSuffix.value = ' bla'
479465 $contentAfterParsing.parameters.parLocation.value = ' eastus'
480466
481467 $contentStringAfterParsing = ConvertTo-Json - InputObject $contentAfterParsing
@@ -485,11 +471,11 @@ InModuleScope 'ALZ' {
485471
486472 It ' Computed, Processed array values replace values correctly' {
487473 $config = [pscustomobject ]@ {
488- Nested = [pscustomobject ]@ {
474+ Nested = [pscustomobject ]@ {
489475 Type = " Computed"
490476 Description = " A Test Value"
491- Process = ' @($args | Select-Object -Unique)'
492- Value = @ (
477+ Process = ' @($args | Select-Object -Unique)'
478+ Value = @ (
493479 " 1" ,
494480 " 1" ,
495481 " 3"
@@ -524,7 +510,7 @@ InModuleScope 'ALZ' {
524510
525511 $expectedContent = Format-ExpectedResult - expectedJson $expectedContent
526512
527- Edit-ALZConfigurationFilesInPlace - alzEnvironmentDestination ' .' - configuration $config
513+ Edit-ALZConfigurationFilesInPlace - alzEnvironmentDestination ' .' - configuration $config
528514
529515 Should - Invoke - CommandName Out-File `
530516 - ParameterFilter { $FilePath -eq $testFile1Name -and $InputObject -eq $expectedContent } `
@@ -533,11 +519,11 @@ InModuleScope 'ALZ' {
533519
534520 It ' Computed, Processed array values replace values correctly in a case insensitive deduplication.' {
535521 $config = [pscustomobject ]@ {
536- Nested = [pscustomobject ]@ {
522+ Nested = [pscustomobject ]@ {
537523 Type = " Computed"
538524 Description = " A Test Value"
539- Process = ' @($args | ForEach-Object { $_.ToLower() } | Select-Object -Unique)'
540- Value = @ (
525+ Process = ' @($args | ForEach-Object { $_.ToLower() } | Select-Object -Unique)'
526+ Value = @ (
541527 " A" ,
542528 " a" ,
543529 " A" ,
@@ -573,7 +559,7 @@ InModuleScope 'ALZ' {
573559
574560 $expectedContent = Format-ExpectedResult - expectedJson $expectedContent
575561
576- Edit-ALZConfigurationFilesInPlace - alzEnvironmentDestination ' .' - configuration $config
562+ Edit-ALZConfigurationFilesInPlace - alzEnvironmentDestination ' .' - configuration $config
577563
578564 Should - Invoke - CommandName Out-File `
579565 - ParameterFilter { $FilePath -eq $testFile1Name -and $InputObject -eq $expectedContent } `
@@ -582,11 +568,11 @@ InModuleScope 'ALZ' {
582568
583569 It ' Computed, Processed array values replace values correctly and keep array type when only one item remains.' {
584570 $config = [pscustomobject ]@ {
585- Nested = [pscustomobject ]@ {
571+ Nested = [pscustomobject ]@ {
586572 Type = " Computed"
587573 Description = " A Test Value"
588- Process = ' @($args | Select-Object -Unique)'
589- Value = @ (
574+ Process = ' @($args | Select-Object -Unique)'
575+ Value = @ (
590576 " 1" ,
591577 " 1" ,
592578 " 1"
@@ -621,7 +607,7 @@ InModuleScope 'ALZ' {
621607
622608 $expectedContent = Format-ExpectedResult - expectedJson $expectedContent
623609
624- Edit-ALZConfigurationFilesInPlace - alzEnvironmentDestination ' .' - configuration $config
610+ Edit-ALZConfigurationFilesInPlace - alzEnvironmentDestination ' .' - configuration $config
625611
626612 Should - Invoke - CommandName Out-File `
627613 - ParameterFilter { $FilePath -eq $testFile1Name -and $InputObject -eq $expectedContent } `
@@ -630,10 +616,10 @@ InModuleScope 'ALZ' {
630616
631617 It ' Computed, Processed values replace values correctly' {
632618 $config = [pscustomobject ]@ {
633- Nested = [pscustomobject ]@ {
619+ Nested = [pscustomobject ]@ {
634620 Type = " Computed"
635621 Description = " A Test Value"
636- Process = ' ($args[0] -eq "eastus") ? "eastus2" : ($args[0] -eq "eastus2") ? "eastus" : $args[0]'
622+ Process = ' ($args[0] -eq "eastus") ? "eastus2" : ($args[0] -eq "eastus2") ? "eastus" : $args[0]'
637623 Value = " eastus"
638624 Targets = @ (
639625 [pscustomobject ]@ {
@@ -665,7 +651,7 @@ InModuleScope 'ALZ' {
665651
666652 $expectedContent = Format-ExpectedResult - expectedJson $expectedContent
667653
668- Edit-ALZConfigurationFilesInPlace - alzEnvironmentDestination ' .' - configuration $config
654+ Edit-ALZConfigurationFilesInPlace - alzEnvironmentDestination ' .' - configuration $config
669655
670656 Should - Invoke - CommandName Out-File `
671657 - ParameterFilter { $FilePath -eq $testFile1Name -and $InputObject -eq $expectedContent } `
@@ -674,10 +660,10 @@ InModuleScope 'ALZ' {
674660
675661 It ' Computed, Processed values replace values correctly' {
676662 $config = [pscustomobject ]@ {
677- Nested = [pscustomobject ]@ {
663+ Nested = [pscustomobject ]@ {
678664 Type = " Computed"
679665 Description = " A Test Value"
680- Process = ' ($args[0] -eq "goodbye") ? "Hello" : "Goodbye"'
666+ Process = ' ($args[0] -eq "goodbye") ? "Hello" : "Goodbye"'
681667 Value = " goodbye"
682668 Targets = @ (
683669 [pscustomobject ]@ {
@@ -709,7 +695,7 @@ InModuleScope 'ALZ' {
709695
710696 $expectedContent = Format-ExpectedResult - expectedJson $expectedContent
711697
712- Edit-ALZConfigurationFilesInPlace - alzEnvironmentDestination ' .' - configuration $config
698+ Edit-ALZConfigurationFilesInPlace - alzEnvironmentDestination ' .' - configuration $config
713699
714700 Should - Invoke - CommandName Out-File `
715701 - ParameterFilter { $FilePath -eq $testFile1Name -and $InputObject -eq $expectedContent } `
@@ -718,7 +704,7 @@ InModuleScope 'ALZ' {
718704
719705 It ' Multiple files with file specific configuration should be changed correctly' {
720706 $defaultConfig = [pscustomobject ]@ {
721- Value1 = [pscustomobject ]@ {
707+ Value1 = [pscustomobject ]@ {
722708 Description = " The prefix that will be added to all resources created by this deployment."
723709 Targets = @ (
724710 [pscustomobject ]@ {
@@ -729,7 +715,7 @@ InModuleScope 'ALZ' {
729715 Value = " value1"
730716 DefaultValue = " alz"
731717 }
732- Value2 = [pscustomobject ]@ {
718+ Value2 = [pscustomobject ]@ {
733719 Description = " The prefix that will be added to all resources created by this deployment."
734720 Targets = @ (
735721 [pscustomobject ]@ {
@@ -760,11 +746,11 @@ InModuleScope 'ALZ' {
760746 Mock - CommandName Get-ChildItem - ParameterFilter { $Path -match ' config$' } - MockWith {
761747 @ (
762748 [PSCustomObject ]@ {
763- Name = ' test1.parameters.json'
749+ Name = ' test1.parameters.json'
764750 FullName = ' test1.parameters.json'
765751 },
766752 [PSCustomObject ]@ {
767- Name = ' test2.parameters.json'
753+ Name = ' test2.parameters.json'
768754 FullName = ' test2.parameters.json'
769755 }
770756 )
@@ -777,7 +763,7 @@ InModuleScope 'ALZ' {
777763 $secondFileContent
778764 }
779765
780- Edit-ALZConfigurationFilesInPlace - alzEnvironmentDestination ' .' - configuration $defaultConfig
766+ Edit-ALZConfigurationFilesInPlace - alzEnvironmentDestination ' .' - configuration $defaultConfig
781767
782768 Should - Invoke - CommandName Out-File - Scope It - Times 2
783769
0 commit comments