Test work
Compare changes
Files
19+ 355
− 0
\ No newline at end of file
This update introduces a comprehensive set of Terraform module development standards and enhances the testing framework for Azure Terraform modules by introducing new testing scripts, configurations, and extensive documentation. Additionally, environment variables and test workflows have been modified to introduce better defaults and improved validation.
infra/modules/.cursor/rules/terraform-module.mdc
main.tf
, variables.tf
, outputs.tf
, etc.).unit
and integration
tests.magefile.go
RESOURCE_GROUP_NAME
in the FindAndRunTests
function if not already provided.Test(module string)
function for executing module-specific test.sh
scripts.
RESOURCE_GROUP_NAME
and LOCATION
if not set.infra/modules/providers/azure/app-insights/test.sh
infra/modules/providers/azure/log-analytics/test.sh
infra/modules/providers/azure/resource-group/test.sh
infra/modules/providers/azure/storage-account/test.sh
testing/main.tf
and unit_test.go
for the following modules:
main.tf
with variable-driven configurations for name
, location
, and tagging.unit_test.go
to utilize dynamic generation of resource group names and better support environment variable overrides.infra/modules/providers/azure/test-functions.sh
setup_configuration
: Handles common Terraform setup for tests.generate_unique_name
: Provides unique name generation for resources.terraform_init_and_apply
: Standardizes Terraform initialization and deployment.run_standard_test_sequence
: Provides a structured flow for unit and integration tests.validate_azure_credentials
), cleanup, logging, and testing utilities.unit_test.go
and integration
tests of specific modules:
ExpectedResourceAttributeValues
improved to validate additional outputs like min_tls_version
and enable_https_traffic_only
.unit_test.go
updated to dynamically pull LOCATION
and RESOURCE_GROUP_NAME
from the environment or generate them as needed.location
, replication_type
, etc.unit_test.go
).
outputs.tf
for resource-group
and storage-account
modules:
main.tf
files for modules (storage-account
, resource-group
, etc.) to explicitly pin the azurerm
provider version (3.90.0
).tf_options.go
to support more flexible integration testing:
ContainerName
, replication_type
, and improved handling of environment overrides.test.sh
scripts handle thorough cleanup via Azure CLI (az group delete
), ensuring no residual artifacts post-tests.terraform plan
as part of the test lifecycle to pre-validate configurations before applying changes.test-functions.sh
) to eliminate redundancies across module configurations.