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

[Modules] Update test folder structure #4181

Merged
merged 12 commits into from
Nov 4, 2023
  •  
  •  
  •  
2 changes: 1 addition & 1 deletion docs/wiki/The library - Module design.md
Original file line number Diff line number Diff line change
Expand Up @@ -629,7 +629,7 @@ Dependency file (`dependencies.bicep`) guidelines:

> :scroll: [Example of test using purge protected Key Vault dependency](https://github.com/Azure/ResourceModules/tree/main/modules/batch/batch-account/.test/encr)

- If you need a Deployment Script to set additional non-template resources up (for example certificates/files, etc.), we recommend to store it as a file in the shared `modules/.shared/.scripts` folder and load it using the template function `loadTextContent()` (for example: `scriptContent: loadTextContent('../../../../.shared/.scripts/New-SSHKey.ps1')`). This approach makes it easier to test & validate the logic and further allows reusing the same logic across multiple test cases.
- If you need a Deployment Script to set additional non-template resources up (for example certificates/files, etc.), we recommend to store it as a file in the shared `modules/.shared/.scripts` folder and load it using the template function `loadTextContent()` (for example: `scriptContent: loadTextContent('../../../../../.shared/.scripts/New-SSHKey.ps1')`). This approach makes it easier to test & validate the logic and further allows reusing the same logic across multiple test cases.

# Telemetry

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ resource certDeploymentScript 'Microsoft.Resources/deploymentScripts@2020-10-01'
azPowerShellVersion: '3.0'
retentionInterval: 'P1D'
arguments: ' -KeyVaultName "${keyVault.name}" -ResourceGroupName "${resourceGroup().name}" -CertPWSecretName "${certPWSecretName}" -CertSecretName "${certSecretName}"'
scriptContent: loadTextContent('../../../../.shared/.scripts/Set-PfxCertificateInKeyVault.ps1')
scriptContent: loadTextContent('../../../../../.shared/.scripts/Set-PfxCertificateInKeyVault.ps1')
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ module nestedDependencies 'dependencies.bicep' = {

// Diagnostics
// ===========
module diagnosticDependencies '../../../../.shared/.templates/diagnostic.dependencies.bicep' = {
module diagnosticDependencies '../../../../../.shared/.templates/diagnostic.dependencies.bicep' = {
scope: resourceGroup
name: '${uniqueString(deployment().name, location)}-diagnosticDependencies'
params: {
Expand All @@ -68,7 +68,7 @@ resource keyVault 'Microsoft.KeyVault/vaults@2022-07-01' existing = {
scope: resourceGroup
}

module testDeployment '../../main.bicep' = {
module testDeployment '../../../main.bicep' = {
scope: resourceGroup
name: '${uniqueString(deployment().name, location)}-test-${serviceShort}'
params: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ module nestedDependencies 'dependencies.bicep' = {

// Diagnostics
// ===========
module diagnosticDependencies '../../../../.shared/.templates/diagnostic.dependencies.bicep' = {
module diagnosticDependencies '../../../../../.shared/.templates/diagnostic.dependencies.bicep' = {
scope: resourceGroup
name: '${uniqueString(deployment().name, location)}-diagnosticDependencies'
params: {
Expand All @@ -60,7 +60,7 @@ module diagnosticDependencies '../../../../.shared/.templates/diagnostic.depende
// Test Execution //
// ============== //

module testDeployment '../../main.bicep' = {
module testDeployment '../../../main.bicep' = {
scope: resourceGroup
name: '${uniqueString(deployment().name, location)}-test-${serviceShort}'
params: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ module nestedDependencies 'dependencies.bicep' = {

// Diagnostics
// ===========
module diagnosticDependencies '../../../../.shared/.templates/diagnostic.dependencies.bicep' = {
module diagnosticDependencies '../../../../../.shared/.templates/diagnostic.dependencies.bicep' = {
scope: resourceGroup
name: '${uniqueString(deployment().name, location)}-diagnosticDependencies'
params: {
Expand All @@ -57,7 +57,7 @@ module diagnosticDependencies '../../../../.shared/.templates/diagnostic.depende
// Test Execution //
// ============== //

module testDeployment '../../main.bicep' = {
module testDeployment '../../../main.bicep' = {
scope: az.resourceGroup(resourceGroupName)
name: '${uniqueString(deployment().name)}-test-${serviceShort}'
params: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ resource resourceGroup 'Microsoft.Resources/resourceGroups@2021-04-01' = {
// Test Execution //
// ============== //

module testDeployment '../../main.bicep' = {
module testDeployment '../../../main.bicep' = {
scope: resourceGroup
name: '${uniqueString(deployment().name, location)}-test-${serviceShort}'
params: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ module nestedDependencies 'dependencies.bicep' = {
// Test Execution //
// ============== //

module testDeployment '../../main.bicep' = {
module testDeployment '../../../main.bicep' = {
scope: resourceGroup
name: '${uniqueString(deployment().name, location)}-test-${serviceShort}'
params: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ module nestedDependencies 'dependencies.bicep' = {

// Diagnostics
// ===========
module diagnosticDependencies '../../../../.shared/.templates/diagnostic.dependencies.bicep' = {
module diagnosticDependencies '../../../../../.shared/.templates/diagnostic.dependencies.bicep' = {
scope: resourceGroup
name: '${uniqueString(deployment().name, location)}-diagnosticDependencies'
params: {
Expand All @@ -61,7 +61,7 @@ module diagnosticDependencies '../../../../.shared/.templates/diagnostic.depende
// Test Execution //
// ============== //

module testDeployment '../../main.bicep' = {
module testDeployment '../../../main.bicep' = {
scope: resourceGroup
name: '${uniqueString(deployment().name, location)}-test-${serviceShort}'
params: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ resource resourceGroup 'Microsoft.Resources/resourceGroups@2021-04-01' = {
// Test Execution //
// ============== //

module testDeployment '../../main.bicep' = {
module testDeployment '../../../main.bicep' = {
scope: resourceGroup
name: '${uniqueString(deployment().name, location)}-test-${serviceShort}'
params: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ module nestedDependencies 'dependencies.bicep' = {

// Diagnostics
// ===========
module diagnosticDependencies '../../../../.shared/.templates/diagnostic.dependencies.bicep' = {
module diagnosticDependencies '../../../../../.shared/.templates/diagnostic.dependencies.bicep' = {
scope: resourceGroup
name: '${uniqueString(deployment().name, location)}-diagnosticDependencies'
params: {
Expand All @@ -60,7 +60,7 @@ module diagnosticDependencies '../../../../.shared/.templates/diagnostic.depende
// Test Execution //
// ============== //

module testDeployment '../../main.bicep' = {
module testDeployment '../../../main.bicep' = {
scope: resourceGroup
name: '${uniqueString(deployment().name, location)}-test-${serviceShort}'
params: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ module nestedDependencies 'dependencies.bicep' = {
// Test Execution //
// ============== //

module testDeployment '../../main.bicep' = {
module testDeployment '../../../main.bicep' = {
scope: resourceGroup
name: '${uniqueString(deployment().name, location)}-test-${serviceShort}'
params: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ resource resourceGroup 'Microsoft.Resources/resourceGroups@2021-04-01' = {
// Test Execution //
// ============== //

module testDeployment '../../main.bicep' = {
module testDeployment '../../../main.bicep' = {
scope: resourceGroup
name: '${uniqueString(deployment().name, location)}-test-${serviceShort}'
params: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ module nestedDependencies 'dependencies.bicep' = {
// Test Execution //
// ============== //

module testDeployment '../../main.bicep' = {
module testDeployment '../../../main.bicep' = {
scope: resourceGroup
name: '${uniqueString(deployment().name, location)}-test-${serviceShort}'
params: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ module nestedDependencies 'dependencies.bicep' = {
// Test Execution //
// ============== //

module testDeployment '../../main.bicep' = {
module testDeployment '../../../main.bicep' = {
scope: resourceGroup
name: '${uniqueString(deployment().name, location)}-test-${serviceShort}'
params: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ module nestedDependencies 'dependencies.bicep' = {
// Test Execution //
// ============== //

module testDeployment '../../main.bicep' = {
module testDeployment '../../../main.bicep' = {
scope: resourceGroup
name: '${uniqueString(deployment().name, location)}-test-${serviceShort}'
params: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ module nestedDependencies 'dependencies.bicep' = {
// Test Execution //
// ============== //

module testDeployment '../../main.bicep' = {
module testDeployment '../../../main.bicep' = {
scope: resourceGroup
name: '${uniqueString(deployment().name, location)}-test-${serviceShort}'
params: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ module nestedDependencies 'dependencies.bicep' = {
// Test Execution //
// ============== //

module testDeployment '../../main.bicep' = {
module testDeployment '../../../main.bicep' = {
scope: resourceGroup
name: '${uniqueString(deployment().name, location)}-test-${serviceShort}'
params: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ module nestedDependencies 'dependencies.bicep' = {
// Test Execution //
// ============== //

module testDeployment '../../main.bicep' = {
module testDeployment '../../../main.bicep' = {
scope: resourceGroup
name: '${uniqueString(deployment().name, location)}-test-${serviceShort}'
params: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ module nestedDependencies 'dependencies.bicep' = {
// Test Execution //
// ============== //

module testDeployment '../../main.bicep' = {
module testDeployment '../../../main.bicep' = {
scope: resourceGroup
name: '${uniqueString(deployment().name, location)}-test-${serviceShort}'
params: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ resource resourceGroup 'Microsoft.Resources/resourceGroups@2021-04-01' = {
// Test Execution //
// ============== //

module testDeployment '../../main.bicep' = {
module testDeployment '../../../main.bicep' = {
name: '${uniqueString(deployment().name, location)}-test-${serviceShort}'
params: {
enableDefaultTelemetry: enableDefaultTelemetry
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ param namePrefix string = '[[namePrefix]]'
// Test Execution //
// ============== //

module testDeployment '../../main.bicep' = {
module testDeployment '../../../main.bicep' = {
name: '${uniqueString(deployment().name, location)}-test-${serviceShort}'
params: {
enableDefaultTelemetry: enableDefaultTelemetry
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ param namePrefix string = '[[namePrefix]]'
// Test Execution //
// ============== //

module testDeployment '../../main.bicep' = {
module testDeployment '../../../main.bicep' = {
name: '${uniqueString(deployment().name)}-test-${serviceShort}'
params: {
enableDefaultTelemetry: enableDefaultTelemetry
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ module nestedDependencies 'dependencies.bicep' = {
// Test Execution //
// ============== //

module testDeployment '../../resource-group/main.bicep' = {
module testDeployment '../../../resource-group/main.bicep' = {
scope: resourceGroup
name: '${uniqueString(deployment().name)}-test-${serviceShort}'
params: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ resource resourceGroup 'Microsoft.Resources/resourceGroups@2021-04-01' = {
// Test Execution //
// ============== //

module testDeployment '../../resource-group/main.bicep' = {
module testDeployment '../../../resource-group/main.bicep' = {
scope: resourceGroup
name: '${uniqueString(deployment().name)}-test-${serviceShort}'
params: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ module nestedDependencies 'dependencies.bicep' = {
// Test Execution //
// ============== //

module testDeployment '../../subscription/main.bicep' = {
module testDeployment '../../../subscription/main.bicep' = {
name: '${uniqueString(deployment().name)}-test-${serviceShort}'
params: {
enableDefaultTelemetry: enableDefaultTelemetry
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ param namePrefix string = '[[namePrefix]]'
// Test Execution //
// ============== //

module testDeployment '../../subscription/main.bicep' = {
module testDeployment '../../../subscription/main.bicep' = {
name: '${uniqueString(deployment().name)}-test-${serviceShort}'
params: {
enableDefaultTelemetry: enableDefaultTelemetry
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ param namePrefix string = '[[namePrefix]]'
// Test Execution //
// ============== //

module testDeployment '../../management-group/main.bicep' = {
module testDeployment '../../../management-group/main.bicep' = {
name: '${uniqueString(deployment().name)}-test-${serviceShort}'
params: {
enableDefaultTelemetry: enableDefaultTelemetry
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ param namePrefix string = '[[namePrefix]]'
// Test Execution //
// ============== //

module testDeployment '../../management-group/main.bicep' = {
module testDeployment '../../../management-group/main.bicep' = {
name: '${uniqueString(deployment().name)}-test-${serviceShort}'
params: {
enableDefaultTelemetry: enableDefaultTelemetry
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ param namePrefix string = '[[namePrefix]]'
// Test Execution //
// ============== //

module testDeployment '../../subscription/main.bicep' = {
module testDeployment '../../../subscription/main.bicep' = {
name: '${uniqueString(deployment().name)}-test-${serviceShort}'
params: {
enableDefaultTelemetry: enableDefaultTelemetry
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ param namePrefix string = '[[namePrefix]]'
// Test Execution //
// ============== //

module testDeployment '../../subscription/main.bicep' = {
module testDeployment '../../../subscription/main.bicep' = {
name: '${uniqueString(deployment().name)}-test-${serviceShort}'
params: {
enableDefaultTelemetry: enableDefaultTelemetry
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ resource policySetAssignment 'Microsoft.Authorization/policyAssignments@2021-06-
// Test Execution //
// ============== //

module testDeployment '../../management-group/main.bicep' = {
module testDeployment '../../../management-group/main.bicep' = {
name: '${uniqueString(deployment().name)}-test-${serviceShort}'
params: {
enableDefaultTelemetry: enableDefaultTelemetry
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ resource policyAssignment 'Microsoft.Authorization/policyAssignments@2021-06-01'
// Test Execution //
// ============== //

module testDeployment '../../management-group/main.bicep' = {
module testDeployment '../../../management-group/main.bicep' = {
name: '${uniqueString(deployment().name)}-test-${serviceShort}'
params: {
enableDefaultTelemetry: enableDefaultTelemetry
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ resource policySetAssignment 'Microsoft.Authorization/policyAssignments@2021-06-
// Test Execution //
// ============== //

module testDeployment '../../resource-group/main.bicep' = {
module testDeployment '../../../resource-group/main.bicep' = {
scope: resourceGroup
name: '${uniqueString(deployment().name)}-test-${serviceShort}'
params: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ resource policyAssignment 'Microsoft.Authorization/policyAssignments@2021-06-01'
// Test Execution //
// ============== //

module testDeployment '../../resource-group/main.bicep' = {
module testDeployment '../../../resource-group/main.bicep' = {
scope: resourceGroup
name: '${uniqueString(deployment().name)}-test-${serviceShort}'
params: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ resource policySetAssignment 'Microsoft.Authorization/policyAssignments@2021-06-
// Test Execution //
// ============== //

module testDeployment '../../subscription/main.bicep' = {
module testDeployment '../../../subscription/main.bicep' = {
name: '${uniqueString(deployment().name)}-test-${serviceShort}'
params: {
enableDefaultTelemetry: enableDefaultTelemetry
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ resource policyAssignment 'Microsoft.Authorization/policyAssignments@2021-06-01'
// Test Execution //
// ============== //

module testDeployment '../../subscription/main.bicep' = {
module testDeployment '../../../subscription/main.bicep' = {
name: '${uniqueString(deployment().name)}-test-${serviceShort}'
params: {
enableDefaultTelemetry: enableDefaultTelemetry
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ param namePrefix string = '[[namePrefix]]'
// Test Execution //
// ============== //

module testDeployment '../../management-group/main.bicep' = {
module testDeployment '../../../management-group/main.bicep' = {
name: '${uniqueString(deployment().name)}-test-${serviceShort}'
params: {
enableDefaultTelemetry: enableDefaultTelemetry
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ param namePrefix string = '[[namePrefix]]'
// Test Execution //
// ============== //

module testDeployment '../../management-group/main.bicep' = {
module testDeployment '../../../management-group/main.bicep' = {
name: '${uniqueString(deployment().name)}-test-${serviceShort}'
params: {
enableDefaultTelemetry: enableDefaultTelemetry
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ param namePrefix string = '[[namePrefix]]'
// Test Execution //
// ============== //

module testDeployment '../../subscription/main.bicep' = {
module testDeployment '../../../subscription/main.bicep' = {
name: '${uniqueString(deployment().name)}-test-${serviceShort}'
params: {
enableDefaultTelemetry: enableDefaultTelemetry
Expand Down
Loading
Loading