mirror of
https://github.com/opentofu/opentofu.git
synced 2025-02-25 18:45:20 -06:00
Merge pull request #215 from opentffoundation/another-test-to-make-sure-runtime-checks-are-fine-with-test
This commit is contained in:
commit
b08614ef11
@ -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,
|
||||
|
8
internal/command/testdata/test/expect_runtime_check_fail/main.tf
vendored
Normal file
8
internal/command/testdata/test/expect_runtime_check_fail/main.tf
vendored
Normal 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"
|
||||
}
|
||||
}
|
1
internal/command/testdata/test/expect_runtime_check_fail/main.tftest.hcl
vendored
Normal file
1
internal/command/testdata/test/expect_runtime_check_fail/main.tftest.hcl
vendored
Normal file
@ -0,0 +1 @@
|
||||
run "test" {}
|
8
internal/command/testdata/test/expect_runtime_check_fail_command_plan/main.tf
vendored
Normal file
8
internal/command/testdata/test/expect_runtime_check_fail_command_plan/main.tf
vendored
Normal 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"
|
||||
}
|
||||
}
|
3
internal/command/testdata/test/expect_runtime_check_fail_command_plan/main.tftest.hcl
vendored
Normal file
3
internal/command/testdata/test/expect_runtime_check_fail_command_plan/main.tftest.hcl
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
run "test" {
|
||||
command = plan
|
||||
}
|
8
internal/command/testdata/test/expect_runtime_check_pass_command_plan_expected/main.tf
vendored
Normal file
8
internal/command/testdata/test/expect_runtime_check_pass_command_plan_expected/main.tf
vendored
Normal 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"
|
||||
}
|
||||
}
|
@ -0,0 +1,6 @@
|
||||
run "test" {
|
||||
command = plan
|
||||
expect_failures = [
|
||||
check.check
|
||||
]
|
||||
}
|
8
internal/command/testdata/test/expect_runtime_check_pass_with_expect/main.tf
vendored
Normal file
8
internal/command/testdata/test/expect_runtime_check_pass_with_expect/main.tf
vendored
Normal 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"
|
||||
}
|
||||
}
|
5
internal/command/testdata/test/expect_runtime_check_pass_with_expect/main.tftest.hcl
vendored
Normal file
5
internal/command/testdata/test/expect_runtime_check_pass_with_expect/main.tftest.hcl
vendored
Normal file
@ -0,0 +1,5 @@
|
||||
run "test" {
|
||||
expect_failures = [
|
||||
check.check
|
||||
]
|
||||
}
|
Loading…
Reference in New Issue
Block a user