Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Fixes] Fixed ConvertTo-ARMTemplate test case #3931

Merged
merged 3 commits into from
Sep 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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