Discovery for terraform test
replicating a mono repo with modules
Set your gcloud ADC
gcloud auth application-default login
And environment variables
export GOOGLE_CLOUD_PROJECT="..."
Navigate to the module to be tested
cd ./modules/bucket
Initialise the module terrform
terraform init
You can run all tests within the modules tests/
folder by running:
terraform test
You should get the following output
tests/integration.tftest.hcl... in progress
run "integration_test"... pass
tests/integration.tftest.hcl... tearing down
tests/integration.tftest.hcl... pass
tests/unit.tftest.hcl... in progress
run "unit_test_valid_name"... pass
run "unit_test_invalid_location"... pass
tests/unit.tftest.hcl... tearing down
tests/unit.tftest.hcl... pass
Success! 3 passed, 0 failed.
You can also specify which tests to run.
A file naming pattern has been used to separate unit tests (plan) from integrations tests (apply).
terraform test -filter=tests/unit.tftest.hcl
terraform test -filter=tests/integration.tftest.hcl