Skip to content

Commit

Permalink
Added test case for parameter description (#1687)
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexanderSehr authored Jul 21, 2022
1 parent c18ff47 commit 280db1a
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions utilities/pipelines/staticValidation/module.tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -928,6 +928,22 @@ Describe 'Deployment template tests' -Tag Template {
$missingParameters.Count | Should -Be 0 -Because ('no required parameters in the template file should be missing in the parameter file. Found missing items: [{0}]' -f ($missingParameters -join ', '))
}
}

It '[<moduleFolderName>] All non-required parameters in template file should not have description that start with "Required."' -TestCases $deploymentFolderTestCases {
param (
[hashtable[]] $testFileTestCases,
[hashtable] $templateContent
)

foreach ($parameterFileTestCase in $testFileTestCases) {
$templateFile_RequiredParametersNames = $parameterFileTestCase.templateFile_RequiredParametersNames
$templateFile_AllParameterNames = $parameterFileTestCase.templateFile_AllParameterNames
$nonRequiredParameterNames = $templateFile_AllParameterNames | Where-Object { $_ -notin $templateFile_RequiredParametersNames }

$incorrectParameters = $nonRequiredParameterNames | Where-Object { ($templateContent.parameters[$_].defaultValue) -and ($templateContent.parameters[$_].metadata.description -like 'Required. *') }
$incorrectParameters.Count | Should -Be 0 -Because ('all non-required parameters in the template file should not have a description that starts with "Required.". Found incorrect items: [{0}]' -f ($incorrectParameters -join ', '))
}
}
}

Context 'Parameter file token tests' {
Expand Down

0 comments on commit 280db1a

Please sign in to comment.