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#`"), }, }, })