Skip to content

Commit cbbf394

Browse files
Updating GH Workflow to validate policy file and meta names are the same (#1711)
Co-authored-by: Jack Tracey <41163455+jtracey93@users.noreply.github.com>
1 parent 0b8d048 commit cbbf394

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

.github/actions-pester/Test-ModifiedPolicies.Tests.ps1

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,21 @@ Describe 'UnitTest-ModifiedPolicies' {
109109
}
110110
}
111111

112+
It "Check policy metadata name matches policy filename" {
113+
$ModifiedAddedFiles | ForEach-Object {
114+
$PolicyJson = Get-Content -Path $_ -Raw | ConvertFrom-Json
115+
$PolicyFile = Split-Path $_ -Leaf
116+
$PolicyMetadataName = $PolicyJson.name
117+
$PolicyFileNoExt = [System.IO.Path]::GetFileNameWithoutExtension($PolicyFile)
118+
if ($PolicyFileNoExt.Contains("AzureChinaCloud") -or $PolicyFileNoExt.Contains("AzureUSGovernment"))
119+
{
120+
$PolicyFileNoExt = $PolicyFileNoExt.Substring(0, $PolicyFileNoExt.IndexOf("."))
121+
}
122+
Write-Warning "$($PolicyFileNoExt) - This is the policy metadata name: $($PolicyMetadataName)"
123+
$PolicyMetadataName | Should -Be $PolicyFileNoExt
124+
}
125+
}
126+
112127
}
113128

114129
Context "Validate policy parameters" {

0 commit comments

Comments
 (0)