Describe the bug
Recently a new change was introduced into the Readme generator script that injects an empty line between Parameter file category tables. This causes the Pester script to fail when it attempts to validate the Parameter file section in the readme as it now sees the value being produced as null compared to the ordered list.
Readme files for all modules need to be regenerated to accommodate the new change and an update to the pester check to ensure that the new line added doesn't impact the test.
In the readme script, the following was added
$newSectionContent += @(
('**{0} parameters**' -f $category),
(''), #### THIS IS THE NEW CHANGE
('| Parameter Name | Type | {0}{1}Description |' -f ($hasDefault ?
In the Pester test, this is the line that was impacted:
$readMeCategoryIndex = $readMeContent | Select-String -Pattern "^\*\*$paramCategory parameters\*\*$" | ForEach-Object { $_.LineNumber }
To solve the issue, { $_.LineNumber } must be changed to { $_.LineNumber + 1} in order to skip the empty line
To reproduce
Rerun any workflow/pipeline, it will fail on the pester checks as the readme files generated do not match what is committed. Then update the readme for any module, you'll notice the new line being added to the parameters table. Then rerun the pipeline again and you will get the following error:
Message
Expected @('Parameter Name', 'Type', 'Default Value', 'Description'), but got $null.
at $readmeCategoryColumns | Should -Be $expectedColumnsInOrder, /home/runner/work/ResourceModules/ResourceModules/utilities/pipelines/staticValidation/module.tests.ps1:347
at <ScriptBlock>, /home/runner/work/ResourceModules/ResourceModules/utilities/pipelines/staticValidation/module.tests.ps1:347
Error: [-] [Microsoft.Authorization/roleDefinitions/subscription] parameter tables should provide columns in the following order: Parameter Name, Type, Default Value, Allowed Values, Description. Each column should be present unless empty for all the rows. 10ms (9ms|1ms)
Code snippet
No response
Relevant log output
Message
Expected @('Parameter Name', 'Type', 'Default Value', 'Description'), but got $null.
at $readmeCategoryColumns | Should -Be $expectedColumnsInOrder, /home/runner/work/ResourceModules/ResourceModules/utilities/pipelines/staticValidation/module.tests.ps1:347
at <ScriptBlock>, /home/runner/work/ResourceModules/ResourceModules/utilities/pipelines/staticValidation/module.tests.ps1:347
Error: [-] [Microsoft.Authorization/roleDefinitions/subscription] parameter tables should provide columns in the following order: Parameter Name, Type, Default Value, Allowed Values, Description. Each column should be present unless empty for all the rows. 10ms (9ms|1ms)
Describe the bug
Recently a new change was introduced into the Readme generator script that injects an empty line between Parameter file category tables. This causes the Pester script to fail when it attempts to validate the Parameter file section in the readme as it now sees the value being produced as
nullcompared to the ordered list.Readme files for all modules need to be regenerated to accommodate the new change and an update to the pester check to ensure that the new line added doesn't impact the test.
In the readme script, the following was added
In the Pester test, this is the line that was impacted:
To solve the issue,
{ $_.LineNumber }must be changed to{ $_.LineNumber + 1}in order to skip the empty lineTo reproduce
Rerun any workflow/pipeline, it will fail on the pester checks as the readme files generated do not match what is committed. Then update the readme for any module, you'll notice the new line being added to the parameters table. Then rerun the pipeline again and you will get the following error:
Code snippet
No response
Relevant log output