From a444b7e6f2467393d2655f9c5400e1c414b0aaff Mon Sep 17 00:00:00 2001 From: Elbaz Date: Tue, 29 Aug 2023 11:17:22 +0300 Subject: [PATCH] expect_runtime_check_fail_command_plan --- internal/command/test_test.go | 10 +++++++++- .../expect_runtime_check_fail_command_plan/main.tf | 8 ++++++++ .../main.tftest.hcl | 3 +++ 3 files changed, 20 insertions(+), 1 deletion(-) create mode 100644 internal/command/testdata/test/expect_runtime_check_fail_command_plan/main.tf create mode 100644 internal/command/testdata/test/expect_runtime_check_fail_command_plan/main.tftest.hcl diff --git a/internal/command/test_test.go b/internal/command/test_test.go index 9956e60f26..c5f261b02d 100644 --- a/internal/command/test_test.go +++ b/internal/command/test_test.go @@ -84,6 +84,10 @@ func TestTest(t *testing.T) { expected: "0 passed, 1 failed.", code: 1, }, + "expect_runtime_check_fail_command_plan": { + expected: "0 passed, 1 failed.", + code: 1, + }, "expect_failures_resources": { expected: "1 passed, 0 failed.", code: 0, @@ -183,7 +187,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 @@ -195,6 +199,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, diff --git a/internal/command/testdata/test/expect_runtime_check_fail_command_plan/main.tf b/internal/command/testdata/test/expect_runtime_check_fail_command_plan/main.tf new file mode 100644 index 0000000000..879a901c0e --- /dev/null +++ b/internal/command/testdata/test/expect_runtime_check_fail_command_plan/main.tf @@ -0,0 +1,8 @@ +resource "test_resource" "resource" {} + +check "check" { + assert { + condition = test_resource.resource.id == "" + error_message = "check block: resource has no id" + } +} \ No newline at end of file diff --git a/internal/command/testdata/test/expect_runtime_check_fail_command_plan/main.tftest.hcl b/internal/command/testdata/test/expect_runtime_check_fail_command_plan/main.tftest.hcl new file mode 100644 index 0000000000..ae482b633c --- /dev/null +++ b/internal/command/testdata/test/expect_runtime_check_fail_command_plan/main.tftest.hcl @@ -0,0 +1,3 @@ +run "test" { + command = plan +}