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

fix: CI - Fixed and expanded upon required/optional validation #3621

Merged
merged 4 commits into from
Oct 26, 2024
Merged
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 @@ -629,7 +629,7 @@ Describe 'Module tests' -Tag 'Module' {

if (-not $isRequired) {
$description = $templateFileParameters.$parameter.metadata.description
if ($description -match "\('Required\.") {
if ($description -match '^Required\.') {
AlexanderSehr marked this conversation as resolved.
Show resolved Hide resolved
$incorrectParameters += $parameter
}
}
Expand All @@ -638,6 +638,27 @@ Describe 'Module tests' -Tag 'Module' {
$incorrectParameters | Should -BeNullOrEmpty -Because ('only required parameters in the template file should have a description that starts with "Required.". Found incorrect items: [{0}].' -f ($incorrectParameters -join ', '))
}

It '[<moduleFolderName>] All required parameters & UDTs in template file should have description that start with "(Required|Conditional).".' -TestCases $moduleFolderTestCases {
param (
[hashtable] $templateFileContent,
[hashtable] $templateFileParameters
)

$incorrectParameters = @()
foreach ($parameter in ($templateFileParameters.PSBase.Keys | Sort-Object -Culture 'en-US')) {
$isRequired = Get-IsParameterRequired -TemplateFileContent $templateFileContent -Parameter $templateFileParameters.$parameter

if ($isRequired) {
$description = $templateFileParameters.$parameter.metadata.description
if ($description -notmatch '^(Required|Conditional)\.') {
$incorrectParameters += $parameter
}
}
}

$incorrectParameters | Should -BeNullOrEmpty -Because ('required parameters in the template file should have a description that starts with "Required.". Found incorrect items: [{0}].' -f ($incorrectParameters -join ', '))
}

Context 'Schema-based User-defined-types tests' -Tag 'UDT' {

# Creating custom test cases for the UDT schema-based tests
Expand Down Expand Up @@ -670,12 +691,12 @@ Describe 'Module tests' -Tag 'Module' {
link = "$interfaceBase/diagnostic-settings"
}
@{
parameterName = 'roleAssignments'
link = "$interfaceBase/role-assignments"
parameterName = 'roleAssignments'
link = "$interfaceBase/role-assignments"
}
@{
parameterName = 'lock'
link = "$interfaceBase/resource-locks"
parameterName = 'lock'
link = "$interfaceBase/resource-locks"
}
@{
parameterName = 'managedIdentities'
Expand Down