From 21c78af06f195a6d60a1b1a7901a03fb39c8e2c2 Mon Sep 17 00:00:00 2001 From: Alexander Sehr Date: Thu, 7 Sep 2023 13:07:36 +0200 Subject: [PATCH] [Fixes] Fixed `ConvertTo-ARMTemplate` test case (#3931) * Fixed param ref * Removed test for a parameter that isn't supported anymore --- .../platform.convertToArmTemplate.tests.yml | 2 +- .../tests/ConvertTo-ARMTemplate.Tests.ps1 | 57 +------------------ 2 files changed, 3 insertions(+), 56 deletions(-) diff --git a/.github/workflows/platform.convertToArmTemplate.tests.yml b/.github/workflows/platform.convertToArmTemplate.tests.yml index 35aa597ae8..b68fcad688 100644 --- a/.github/workflows/platform.convertToArmTemplate.tests.yml +++ b/.github/workflows/platform.convertToArmTemplate.tests.yml @@ -16,7 +16,7 @@ jobs: strategy: fail-fast: false matrix: - tags: ['Default', 'ConvertChildren', 'Skip'] + tags: ['Default', 'Skip'] steps: - name: 'Checkout' uses: actions/checkout@v3 diff --git a/utilities/tools/tests/ConvertTo-ARMTemplate.Tests.ps1 b/utilities/tools/tests/ConvertTo-ARMTemplate.Tests.ps1 index f295039a82..c991acb586 100644 --- a/utilities/tools/tests/ConvertTo-ARMTemplate.Tests.ps1 +++ b/utilities/tools/tests/ConvertTo-ARMTemplate.Tests.ps1 @@ -37,7 +37,7 @@ BeforeAll { Describe 'Test default behavior' -Tag 'Default' { BeforeAll { - ConvertTo-ARMTemplate -Path $rootPath -Verbose -RunSynchronous + ConvertTo-ARMTemplate -RootPath $rootPath -Verbose -RunSynchronous } It 'All [] top-level [main.bicep] files are converted to [main.json]' { @@ -87,63 +87,10 @@ Describe 'Test default behavior' -Tag 'Default' { } } -Describe 'Test flag to including children' -Tag 'ConvertChildren' { - - BeforeAll { - ConvertTo-ARMTemplate -Path $rootPath -ConvertChildren -Verbose -RunSynchronous - } - - It 'All [] [main.bicep] files are converted to [main.json]' { - $deployJsonFilesCount = (Get-ChildItem -Recurse $modulesFolderPath | Where-Object { $_.FullName -match 'main.json' }).Count - $deployJsonFilesCount | Should -Be $allBicepDeployFilesCount - } - - It 'All [] [main.test.bicep] files are converted to [main.test.json]' { - $deployJsonFilesCount = (Get-ChildItem -Recurse $modulesFolderPath | Where-Object { $_.FullName -match 'main.test.json' }).Count - $deployJsonFilesCount | Should -Be $bicepTestFilesCount - } - - It 'All bicep files are removed' { - $actualBicepFilesCount = (Get-ChildItem -Recurse $modulesFolderPath | Where-Object { $_.FullName -match '.*.bicep' }).Count - $actualBicepFilesCount | Should -Be 0 - } - - It 'All json files have metadata removed' { - $releveantJSONFiles = (Get-ChildItem -Recurse $modulesFolderPath).FullName | Where-Object { $_ -match '.+(main.json|main.test.json)$' } - - $metadataFound = $false - - foreach ($deployJsonFile in $deployJsonFiles) { - $TemplateObject = Get-Content -Path $deployJsonFile -Raw | ConvertFrom-Json -AsHashtable - - if ([bool]($TemplateObject.Keys -contains 'metadata')) { - $metadataFound = $true - break - } - } - - $metadataFound | Should -Be $false - } - - It 'All [] GitHub workflow files are updated' { - $moduleWorkflowFilesUpdated = 0 - - foreach ($workFlowFile in $moduleWorkflowFiles) { - foreach ($line in (Get-Content -Path $workFlowFile.FullName)) { - if ($line -like '*templateFilePath:*.json*') { - $moduleWorkflowFilesUpdated += 1 - break - } - } - } - $moduleWorkflowFilesUpdated | Should -Be $originalModuleWorkflowWithBicep - } -} - Describe 'Test flags that skip logic' -Tag 'Skip' { BeforeAll { - ConvertTo-ARMTemplate -Path $rootPath -SkipBicepCleanUp -SkipMetadataCleanup -SkipPipelineUpdate -Verbose -RunSynchronous + ConvertTo-ARMTemplate -RootPath $rootPath -SkipBicepCleanUp -SkipMetadataCleanup -SkipPipelineUpdate -Verbose -RunSynchronous } It 'All [] main.bicep files are converted to main.json' {