Complete the code to define a basic Terraform test block.
test "example" { [1] = "." }
The source attribute specifies the location of the Terraform module or configuration to test.
Complete the code to run a Terraform plan in the test block.
test "plan_test" { source = "./module" [1] { run = "terraform plan" } }
The steps block defines commands to run during the test, like 'terraform plan'.
Fix the error in the test assertion syntax.
test "assert_test" { source = "./module" steps { run = "terraform apply -auto-approve" } [1] { condition = "length(terraform_output.ids) > 0" } }
The correct block name for assertions is assert.
Fill both blanks to define a test with setup and teardown steps.
test "full_test" { source = "./module" [1] { run = "terraform init" } [2] { run = "terraform destroy -auto-approve" } }
The setup block runs before tests, and teardown runs after to clean resources.
Fill all three blanks to assert output values correctly.
test "output_assert" { source = "./module" steps { run = "terraform apply -auto-approve" } assert { condition = "terraform_output.[1] == '[2]'" message = "Output value should be [3]" } }
The output name is 'my_output'. The condition compares it to the expected value. The message repeats the expected value.
