Skip to content

Commit cc4c3ff

Browse files
committed
Adding test for Namespace Already Exists
1 parent 213d0bc commit cc4c3ff

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

internal/provider/namespace_resource_test.go

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package provider_test
22

33
import (
4+
"regexp"
45
"testing"
56

67
"github.com/hashicorp/terraform-plugin-testing/helper/resource"
@@ -50,3 +51,31 @@ resource "temporal_namespace" "test" {
5051
},
5152
})
5253
}
54+
55+
func TestAccNamespaceAlreadyExsits(t *testing.T) {
56+
resource.Test(t, resource.TestCase{
57+
ProtoV6ProviderFactories: testAccProtoV6ProviderFactories,
58+
Steps: []resource.TestStep{
59+
// Create and Read testing
60+
{
61+
Config: providerConfig + `
62+
resource "temporal_namespace" "test1" {
63+
name = "test"
64+
description = "This is a test namespace"
65+
owner_email = "[email protected]"
66+
}`,
67+
},
68+
// Namespace already exists Error
69+
{
70+
Config: providerConfig + `
71+
resource "temporal_namespace" "test2" {
72+
name = "test"
73+
description = "This is a test namespace"
74+
owner_email = "[email protected]"
75+
}
76+
`,
77+
ExpectError: regexp.MustCompile("namespace registration failed.*code = AlreadyExists"),
78+
},
79+
},
80+
})
81+
}

0 commit comments

Comments
 (0)