Merge pull request #215 from opentffoundation/another-test-to-make-sure-runtime-checks-are-fine-with-test

This commit is contained in:
Elbaz 2023-08-29 14:55:48 +03:00 committed by GitHub
commit b08614ef11
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 68 additions and 1 deletions

View File

@ -76,6 +76,22 @@ func TestTest(t *testing.T) {
expected: "1 passed, 0 failed.",
code: 0,
},
"expect_runtime_check_fail": {
expected: "0 passed, 1 failed.",
code: 1,
},
"expect_runtime_check_pass_with_expect": {
expected: "1 passed, 0 failed.",
code: 0,
},
"expect_runtime_check_pass_command_plan_expected": {
expected: "1 passed, 0 failed.",
code: 0,
},
"expect_runtime_check_fail_command_plan": {
expected: "0 passed, 1 failed.",
code: 1,
},
"expect_failures_resources": {
expected: "1 passed, 0 failed.",
code: 0,
@ -175,7 +191,7 @@ func TestTest(t *testing.T) {
})
}
}
func TestTest_Broken_HCL_Files(t *testing.T) {
func TestTest_Broken_Full_Output(t *testing.T) {
tcs := map[string]struct {
override string
args []string
@ -187,6 +203,10 @@ func TestTest_Broken_HCL_Files(t *testing.T) {
expected: "Unsupported block type",
code: 1,
},
"expect_runtime_check_fail_command_plan": {
expected: "Check block assertion known after apply",
code: 1,
},
"broken_wrong_block_resource": {
expected: "Blocks of type \"resource\" are not expected here.",
code: 1,

View File

@ -0,0 +1,8 @@
resource "test_resource" "resource" {}
check "check" {
assert {
condition = test_resource.resource.id == ""
error_message = "check block: resource has no id"
}
}

View File

@ -0,0 +1 @@
run "test" {}

View File

@ -0,0 +1,8 @@
resource "test_resource" "resource" {}
check "check" {
assert {
condition = test_resource.resource.id == ""
error_message = "check block: resource has no id"
}
}

View File

@ -0,0 +1,3 @@
run "test" {
command = plan
}

View File

@ -0,0 +1,8 @@
resource "test_resource" "resource" {}
check "check" {
assert {
condition = test_resource.resource.id == ""
error_message = "check block: resource has no id"
}
}

View File

@ -0,0 +1,6 @@
run "test" {
command = plan
expect_failures = [
check.check
]
}

View File

@ -0,0 +1,8 @@
resource "test_resource" "resource" {}
check "check" {
assert {
condition = test_resource.resource.id == ""
error_message = "check block: resource has no id"
}
}

View File

@ -0,0 +1,5 @@
run "test" {
expect_failures = [
check.check
]
}