From 9157fc7e10989709e319ac5ed57680557cf172fd Mon Sep 17 00:00:00 2001 From: Lars With Date: Mon, 12 Aug 2024 12:43:27 +0200 Subject: [PATCH] add test for not existing policy --- internal/provider/data_source_policy_test.go | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/internal/provider/data_source_policy_test.go b/internal/provider/data_source_policy_test.go index 7fee5ab7..062dff21 100644 --- a/internal/provider/data_source_policy_test.go +++ b/internal/provider/data_source_policy_test.go @@ -1,6 +1,7 @@ package provider import ( + "regexp" "testing" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" @@ -17,6 +18,10 @@ func TestAccDataSourcePolicy(t *testing.T) { resource.TestCheckResourceAttr("data.authentik_policy.default-authentication-flow-password-stage", "name", "default-authentication-flow-password-stage"), ), }, + { + Config: testAccDataSourcePolicyNotExisting, + ExpectError: regexp.MustCompile(`No matching policy found`), + }, }, }) } @@ -26,3 +31,9 @@ data "authentik_policy" "default-authentication-flow-password-stage" { name = "default-authentication-flow-password-stage" } ` + +const testAccDataSourcePolicyNotExisting = ` +data "authentik_policy" "not-exiting-policy" { + name = "not-exiting-policy" +} +`