From 1b737319ef21194645ac8d5d2d47aa0e337bceba Mon Sep 17 00:00:00 2001 From: Kyle Kotowick Date: Wed, 25 Dec 2024 14:19:10 -0800 Subject: [PATCH] Add delayed message tests --- .github/workflows/CICD.yml | 46 ++++++++++++++----- .gitignore | 2 + .../main.tf | 0 tests/fail-message-delayed/main.tf | 6 +++ .../main.tf | 0 tests/pass-message-delayed/main.tf | 6 +++ 6 files changed, 48 insertions(+), 12 deletions(-) rename tests/{fail-delayed => fail-condition-delayed}/main.tf (100%) create mode 100644 tests/fail-message-delayed/main.tf rename tests/{pass-delayed => pass-condition-delayed}/main.tf (100%) create mode 100644 tests/pass-message-delayed/main.tf diff --git a/.github/workflows/CICD.yml b/.github/workflows/CICD.yml index b3a9d63..9bccec6 100644 --- a/.github/workflows/CICD.yml +++ b/.github/workflows/CICD.yml @@ -49,16 +49,27 @@ jobs: with: tf_path: tests/pass-output - - name: Initialize - Pass - Delayed - id: init-pass-delayed + - name: Initialize - Pass - Condition Delayed + id: init-pass-condition-delayed uses: Invicton-Labs/terraform-module-testing/initialize@v0.2.0 with: - tf_path: tests/pass-delayed - - name: Run Tests - Pass - Delayed - id: tests-pass-delayed + tf_path: tests/pass-condition-delayed + - name: Run Tests - Pass - Condition Delayed + id: tests-pass-condition-delayed uses: Invicton-Labs/terraform-module-testing/apply-destroy@v0.2.0 with: - tf_path: tests/pass-delayed + tf_path: tests/pass-condition-delayed + + - name: Initialize - Pass - Message Delayed + id: init-pass-message-delayed + uses: Invicton-Labs/terraform-module-testing/initialize@v0.2.0 + with: + tf_path: tests/pass-message-delayed + - name: Run Tests - Pass - Message Delayed + id: tests-pass-message-delayed + uses: Invicton-Labs/terraform-module-testing/apply-destroy@v0.2.0 + with: + tf_path: tests/pass-message-delayed - name: Initialize - Fail id: init-fail @@ -82,16 +93,27 @@ jobs: with: tf_path: tests/fail-output - - name: Initialize - Fail - Delayed - id: init-fail-delayed + - name: Initialize - Fail - Condition Delayed + id: init-fail-condition-delayed + uses: Invicton-Labs/terraform-module-testing/initialize@v0.2.0 + with: + tf_path: tests/fail-condition-delayed + - name: Run Tests - Fail - Condition Delayed + id: tests-fail-condition-delayed + uses: Invicton-Labs/terraform-module-testing/apply-failure@v0.2.0 + with: + tf_path: tests/fail-condition-delayed + + - name: Initialize - Fail - Message Delayed + id: init-fail-message-delayed uses: Invicton-Labs/terraform-module-testing/initialize@v0.2.0 with: - tf_path: tests/fail-delayed - - name: Run Tests - Fail - Delayed - id: tests-fail-delayed + tf_path: tests/fail-message-delayed + - name: Run Tests - Fail - Message Delayed + id: tests-fail-message-delayed uses: Invicton-Labs/terraform-module-testing/apply-failure@v0.2.0 with: - tf_path: tests/fail-delayed + tf_path: tests/fail-message-delayed # 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 diff --git a/.gitignore b/.gitignore index 7a3e2fd..3017b18 100644 --- a/.gitignore +++ b/.gitignore @@ -27,3 +27,5 @@ override.tf.json # Include tfplan files to ignore the plan output of command: terraform plan -out=tfplan # example: *tfplan* + +/tests/**/.terraform.lock.hcl \ No newline at end of file diff --git a/tests/fail-delayed/main.tf b/tests/fail-condition-delayed/main.tf similarity index 100% rename from tests/fail-delayed/main.tf rename to tests/fail-condition-delayed/main.tf diff --git a/tests/fail-message-delayed/main.tf b/tests/fail-message-delayed/main.tf new file mode 100644 index 0000000..707ea91 --- /dev/null +++ b/tests/fail-message-delayed/main.tf @@ -0,0 +1,6 @@ +module "fail" { + source = "../../" + // Use a condition that isn't known until the apply step + condition = false + error_message = uuid() == "" ? "should never happen" : "sample error" +} diff --git a/tests/pass-delayed/main.tf b/tests/pass-condition-delayed/main.tf similarity index 100% rename from tests/pass-delayed/main.tf rename to tests/pass-condition-delayed/main.tf diff --git a/tests/pass-message-delayed/main.tf b/tests/pass-message-delayed/main.tf new file mode 100644 index 0000000..97bfe9c --- /dev/null +++ b/tests/pass-message-delayed/main.tf @@ -0,0 +1,6 @@ +module "pass" { + source = "../../" + // Use a condition that isn't known until the apply step + condition = uuid() != "" + error_message = uuid() == "" ? "should never happen" : "sample error" +}