From 7d2dc221a43a5807812a82dbbd370952ae3d0b94 Mon Sep 17 00:00:00 2001 From: Scott Talbot Date: Sun, 10 Nov 2024 23:41:56 +1100 Subject: [PATCH] test(provider/preview_api_key): test reading a nonexistent api key --- .../preview_api_key_data_source_test.go | 27 +++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 internal/provider/preview_api_key_data_source_test.go diff --git a/internal/provider/preview_api_key_data_source_test.go b/internal/provider/preview_api_key_data_source_test.go new file mode 100644 index 0000000..f3b1958 --- /dev/null +++ b/internal/provider/preview_api_key_data_source_test.go @@ -0,0 +1,27 @@ +package provider_test + +import ( + "regexp" + "testing" + + "github.com/hashicorp/terraform-plugin-testing/helper/resource" +) + +func TestAccPreviewApiKeyResourceImportNotFound(t *testing.T) { + t.Parallel() + + resource.Test(t, resource.TestCase{ + ProtoV6ProviderFactories: testAccProtoV6ProviderFactories, + Steps: []resource.TestStep{ + { + Config: ` + data "contentful_preview_api_key" "test" { + space_id = "0p38pssr0fi3" + preview_api_key_id = "unknown" + } + `, + ExpectError: regexp.MustCompile(`Failed to read preview api key`), + }, + }, + }) +}