Skip to content

Commit

Permalink
[Fixes] Fixed ConvertTo-ARMTemplate test case (#3931)
Browse files Browse the repository at this point in the history
* Fixed param ref

* Removed test for a parameter that isn't supported anymore
  • Loading branch information
AlexanderSehr authored Sep 7, 2023
1 parent bf62f78 commit 21c78af
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 56 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/platform.convertToArmTemplate.tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
strategy:
fail-fast: false
matrix:
tags: ['Default', 'ConvertChildren', 'Skip']
tags: ['Default', 'Skip']
steps:
- name: 'Checkout'
uses: actions/checkout@v3
Expand Down
57 changes: 2 additions & 55 deletions utilities/tools/tests/ConvertTo-ARMTemplate.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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 [<topLevelBicepDeployFilesCount>] top-level [main.bicep] files are converted to [main.json]' {
Expand Down Expand Up @@ -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 [<allBicepDeployFilesCount>] [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 [<bicepTestFilesCount>] [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 [<originalModuleWorkflowWithBicep>] 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 [<allBicepDeployFilesCount>] main.bicep files are converted to main.json' {
Expand Down

0 comments on commit 21c78af

Please sign in to comment.