From b95683eb255367508bec7874694608b97a761e8f Mon Sep 17 00:00:00 2001 From: Kyle Kotowick Date: Wed, 25 Dec 2024 09:02:10 -0800 Subject: [PATCH] Update version, add tests for forced output checking --- .github/workflows/CICD.yml | 24 +++++++++++++++++++++++- tests/fail-output/.terraform.lock.hcl | 22 ++++++++++++++++++++++ tests/fail-output/main.tf | 11 +++++++++++ tests/pass-output/.terraform.lock.hcl | 22 ++++++++++++++++++++++ tests/pass-output/main.tf | 11 +++++++++++ versions.tf | 2 +- 6 files changed, 90 insertions(+), 2 deletions(-) create mode 100644 tests/fail-output/.terraform.lock.hcl create mode 100644 tests/fail-output/main.tf create mode 100644 tests/pass-output/.terraform.lock.hcl create mode 100644 tests/pass-output/main.tf diff --git a/.github/workflows/CICD.yml b/.github/workflows/CICD.yml index 271d828..f54a435 100644 --- a/.github/workflows/CICD.yml +++ b/.github/workflows/CICD.yml @@ -11,7 +11,7 @@ jobs: id: matrix uses: Invicton-Labs/terraform-module-testing/matrix@v0.2.0 with: - minimum_tf_version: '1.9.0' + minimum_tf_version: '1.10.3' - name: Output Matrix run: | @@ -37,6 +37,17 @@ jobs: with: tf_path: tests/pass + - name: Initialize - Pass (With Output) + id: init-pass-output + uses: Invicton-Labs/terraform-module-testing/initialize@v0.2.0 + with: + tf_path: tests/pass-output + - name: Run Tests - Pass (With Output) + id: tests-pass-output + uses: Invicton-Labs/terraform-module-testing/apply-destroy@v0.2.0 + with: + tf_path: tests/pass-output + - name: Initialize - Fail id: init-fail uses: Invicton-Labs/terraform-module-testing/initialize@v0.2.0 @@ -48,6 +59,17 @@ jobs: with: tf_path: tests/fail + - name: Initialize - Fail (Output) + id: init-fail-output + uses: Invicton-Labs/terraform-module-testing/initialize@v0.2.0 + with: + tf_path: tests/fail-output + - name: Run Tests - Fail (Output) + id: tests-fail-output + uses: Invicton-Labs/terraform-module-testing/apply-failure@v0.2.0 + with: + tf_path: tests/fail-output + # This job just waits for all other jobs to pass. We have it here # so our branch protection rule can reference a single job, instead # of needing to list every matrix value of every job above. diff --git a/tests/fail-output/.terraform.lock.hcl b/tests/fail-output/.terraform.lock.hcl new file mode 100644 index 0000000..db7a7c3 --- /dev/null +++ b/tests/fail-output/.terraform.lock.hcl @@ -0,0 +1,22 @@ +# This file is maintained automatically by "terraform init". +# Manual edits may be lost in future updates. + +provider "registry.terraform.io/hashicorp/cloudinit" { + version = "2.3.2" + constraints = ">= 2.3.1" + hashes = [ + "h1:2jb+BfT5T96dXxUD2LQ6MtVHpXErd7ZybmMvdWE2jd4=", + "zh:2487e498736ed90f53de8f66fe2b8c05665b9f8ff1506f751c5ee227c7f457d1", + "zh:3d8627d142942336cf65eea6eb6403692f47e9072ff3fa11c3f774a3b93130b3", + "zh:434b643054aeafb5df28d5529b72acc20c6f5ded24decad73b98657af2b53f4f", + "zh:436aa6c2b07d82aa6a9dd746a3e3a627f72787c27c80552ceda6dc52d01f4b6f", + "zh:458274c5aabe65ef4dbd61d43ce759287788e35a2da004e796373f88edcaa422", + "zh:54bc70fa6fb7da33292ae4d9ceef5398d637c7373e729ed4fce59bd7b8d67372", + "zh:78d5eefdd9e494defcb3c68d282b8f96630502cac21d1ea161f53cfe9bb483b3", + "zh:893ba267e18749c1a956b69be569f0d7bc043a49c3a0eb4d0d09a8e8b2ca3136", + "zh:95493b7517bce116f75cdd4c63b7c82a9d0d48ec2ef2f5eb836d262ef96d0aa7", + "zh:9ae21ab393be52e3e84e5cce0ef20e690d21f6c10ade7d9d9d22b39851bfeddc", + "zh:cc3b01ac2472e6d59358d54d5e4945032efbc8008739a6d4946ca1b621a16040", + "zh:f23bfe9758f06a1ec10ea3a81c9deedf3a7b42963568997d84a5153f35c5839a", + ] +} diff --git a/tests/fail-output/main.tf b/tests/fail-output/main.tf new file mode 100644 index 0000000..16ca369 --- /dev/null +++ b/tests/fail-output/main.tf @@ -0,0 +1,11 @@ +module "fail" { + source = "../../" + condition = false + error_message = "sample error" +} + +// Force the module and conditions to be evaluated +// by using the module output in a config output. +output "result" { + value = module.fail.checked +} diff --git a/tests/pass-output/.terraform.lock.hcl b/tests/pass-output/.terraform.lock.hcl new file mode 100644 index 0000000..db7a7c3 --- /dev/null +++ b/tests/pass-output/.terraform.lock.hcl @@ -0,0 +1,22 @@ +# This file is maintained automatically by "terraform init". +# Manual edits may be lost in future updates. + +provider "registry.terraform.io/hashicorp/cloudinit" { + version = "2.3.2" + constraints = ">= 2.3.1" + hashes = [ + "h1:2jb+BfT5T96dXxUD2LQ6MtVHpXErd7ZybmMvdWE2jd4=", + "zh:2487e498736ed90f53de8f66fe2b8c05665b9f8ff1506f751c5ee227c7f457d1", + "zh:3d8627d142942336cf65eea6eb6403692f47e9072ff3fa11c3f774a3b93130b3", + "zh:434b643054aeafb5df28d5529b72acc20c6f5ded24decad73b98657af2b53f4f", + "zh:436aa6c2b07d82aa6a9dd746a3e3a627f72787c27c80552ceda6dc52d01f4b6f", + "zh:458274c5aabe65ef4dbd61d43ce759287788e35a2da004e796373f88edcaa422", + "zh:54bc70fa6fb7da33292ae4d9ceef5398d637c7373e729ed4fce59bd7b8d67372", + "zh:78d5eefdd9e494defcb3c68d282b8f96630502cac21d1ea161f53cfe9bb483b3", + "zh:893ba267e18749c1a956b69be569f0d7bc043a49c3a0eb4d0d09a8e8b2ca3136", + "zh:95493b7517bce116f75cdd4c63b7c82a9d0d48ec2ef2f5eb836d262ef96d0aa7", + "zh:9ae21ab393be52e3e84e5cce0ef20e690d21f6c10ade7d9d9d22b39851bfeddc", + "zh:cc3b01ac2472e6d59358d54d5e4945032efbc8008739a6d4946ca1b621a16040", + "zh:f23bfe9758f06a1ec10ea3a81c9deedf3a7b42963568997d84a5153f35c5839a", + ] +} diff --git a/tests/pass-output/main.tf b/tests/pass-output/main.tf new file mode 100644 index 0000000..0ec99a3 --- /dev/null +++ b/tests/pass-output/main.tf @@ -0,0 +1,11 @@ +module "pass" { + source = "../../" + condition = true + error_message = "sample error" +} + +// Force the module and conditions to be evaluated +// by using the module output in a config output. +output "result" { + value = module.pass.checked +} diff --git a/versions.tf b/versions.tf index bfb98ab..12bb31a 100644 --- a/versions.tf +++ b/versions.tf @@ -1,3 +1,3 @@ terraform { - required_version = ">= 1.9.0" + required_version = ">= 1.10.3" }