Skip to content

Commit 169bd23

Browse files
committed
tests(examples): do not run test-function on single terraform apply
Run only test-execution module during terraform test and not during terraform apply.
1 parent f8303d5 commit 169bd23

File tree

7 files changed

+24
-0
lines changed

7 files changed

+24
-0
lines changed

examples/autoscaling-scheduler-terminate-instances/terraform.tftest.hcl

+4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
run "create_test_infrastructure" {
22
command = apply
33

4+
variables {
5+
test_mode = true
6+
}
7+
48
assert {
59
condition = module.autoscaling-stop-friday.scheduler_lambda_name == "stop-autoscaling-${random_pet.suffix.id}"
610
error_message = "Invalid Stop lambda name"

examples/autoscaling-scheduler/main.tf

+1
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,7 @@ module "autoscaling-start-monday" {
107107
}
108108

109109
module "test-execution" {
110+
count = var.test_mode ? 1 : 0
110111
source = "./test-execution"
111112

112113
lambda_stop_name = module.autoscaling-stop-friday.scheduler_lambda_name

examples/autoscaling-scheduler/terraform.tftest.hcl

+4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
run "create_test_infrastructure" {
22
command = apply
33

4+
variables {
5+
test_mode = true
6+
}
7+
48
assert {
59
condition = module.autoscaling-stop-friday.scheduler_lambda_name == "stop-autoscaling-${random_pet.suffix.id}"
610
error_message = "Invalid Stop lambda name"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
variable "test_mode" {
2+
description = "Whether to run in test mode"
3+
type = bool
4+
default = false
5+
}

examples/instance-scheduler/main.tf

+1
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ module "ec2-start-monday" {
7676
}
7777

7878
module "test-execution" {
79+
count = var.test_mode ? 1 : 0
7980
source = "./test-execution"
8081

8182
lambda_stop_name = module.ec2-stop-friday.scheduler_lambda_name

examples/instance-scheduler/terraform.tftest.hcl

+4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
run "create_test_infrastructure" {
22
command = apply
33

4+
variables {
5+
test_mode = true
6+
}
7+
48
assert {
59
condition = module.ec2-stop-friday.scheduler_lambda_name == "stop-ec2-${random_pet.suffix.id}"
610
error_message = "Invalid Stop lambda name"
+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
variable "test_mode" {
2+
description = "Whether to run in test mode"
3+
type = bool
4+
default = false
5+
}

0 commit comments

Comments
 (0)