From f984e7589ca0f42baac58d4ff038a24ccfe7300e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?F=C3=A1bio=20Matavelli?= Date: Thu, 12 Sep 2024 14:53:45 +0100 Subject: [PATCH] chore: add more information to error --- drpv4/resource_drp_subnet_test.go | 28 +++++++++++++++++++--------- 1 file changed, 19 insertions(+), 9 deletions(-) diff --git a/drpv4/resource_drp_subnet_test.go b/drpv4/resource_drp_subnet_test.go index 3e9dbbe..231e2a9 100644 --- a/drpv4/resource_drp_subnet_test.go +++ b/drpv4/resource_drp_subnet_test.go @@ -85,31 +85,41 @@ func TestAccResourceSubnet(t *testing.T) { { Config: ` resource "drp_subnet" "test" { - name = "test#" + name = "test1" description = "test subnet" subnet = "192.168.0.0/24" active_start = "192.168.0.1" active_end = "192.168.0.255" } `, - ExpectError: regexp.MustCompile("Invalid Name `test#`"), + ExpectNonEmptyPlan: true, + ExpectError: regexp.MustCompile("Not Found"), + PreConfig: func() { + t.Log("Removing subnet using DRP API to test terraform error handling") + client := testAccProvider.Meta().(*Config) + r, err := client.session.ListModel("subnets") + if err != nil { + t.Fatal("failed to list subnets") + } + t.Logf("got response: %v", r) + + _, err = client.session.DeleteModel("subnets", "test1") + if err != nil { + t.Fatalf("failed to remove subnet using DRP API: %v", err) + } + }, }, { Config: ` resource "drp_subnet" "test" { - name = "test1" + name = "test#" description = "test subnet" subnet = "192.168.0.0/24" active_start = "192.168.0.1" active_end = "192.168.0.255" } `, - ExpectNonEmptyPlan: true, - ExpectError: regexp.MustCompile("Not Found"), - PreConfig: func() { - client := testAccProvider.Meta().(*Config) - client.session.DeleteModel("subnets", "test1") - }, + ExpectError: regexp.MustCompile("Invalid Name `test#`"), }, }, })