Skip to content

Commit

Permalink
fix: Enable UDT schema tests to differentiate modules that uses the `…
Browse files Browse the repository at this point in the history
…sys` namespace explicitely (#760)

## Description

Some modules (like Compute Gallery) must use metadata annotations using
the `sys` namespace (e.g., @sys.description('...'). Up until now, when
testing the implementation against the schema, Pester would complain
about those cases. This was fixed by detecting if the `sys` namespace
was used and if so, updating the expected schema.

Before:

![image](https://github.com/Azure/bicep-registry-modules/assets/5365358/5db88faa-32bb-4cf5-b533-e5d39c8989ef)

After:

![image](https://github.com/Azure/bicep-registry-modules/assets/5365358/2d021b1e-aca7-44e5-9728-b7c6e5bf92a9)

---------

Co-authored-by: Erika Gressi <56914614+eriqua@users.noreply.github.com>
  • Loading branch information
AlexanderSehr and eriqua authored Jan 2, 2024
1 parent 77913e2 commit 2d404d1
Showing 1 changed file with 5 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1101,6 +1101,11 @@ Describe 'Module tests' -Tag 'Module' {
}
$expectedSchema = $expectedSchemaFull[$expectedSchemaStartIndex..$expectedSchemaEndIndex]

if ($templateFileContentBicep -match '@sys\.([a-zA-Z]+)\(') {
# Handing cases where the template may use the @sys namespace explicitely
$expectedSchema = $expectedSchema | ForEach-Object { $_ -replace '@([a-zA-Z]+)\(', '@sys.$1(' }
}

$formattedDiff = @()
foreach ($finding in (Compare-Object $implementedSchema $expectedSchema)) {
if ($finding.SideIndicator -eq '=>') {
Expand Down

0 comments on commit 2d404d1

Please sign in to comment.