Skip to content

Commit

Permalink
Add test case revealing issue hashicorp#115 when adding annotations t…
Browse files Browse the repository at this point in the history
…o a resource that didn't have any
  • Loading branch information
pdecat committed Feb 12, 2018
1 parent f060690 commit cc09e9a
Showing 1 changed file with 22 additions and 1 deletion.
23 changes: 22 additions & 1 deletion kubernetes/resource_kubernetes_namespace_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,19 @@ func TestAccKubernetesNamespace_basic(t *testing.T) {
Steps: []resource.TestStep{
{
Config: testAccKubernetesNamespaceConfig_basic(nsName),
Check: resource.ComposeAggregateTestCheckFunc(
testAccCheckKubernetesNamespaceExists("kubernetes_namespace.test", &conf),
resource.TestCheckResourceAttr("kubernetes_namespace.test", "metadata.0.annotations.%", "0"),
resource.TestCheckResourceAttr("kubernetes_namespace.test", "metadata.0.labels.%", "0"),
resource.TestCheckResourceAttr("kubernetes_namespace.test", "metadata.0.name", nsName),
resource.TestCheckResourceAttrSet("kubernetes_namespace.test", "metadata.0.generation"),
resource.TestCheckResourceAttrSet("kubernetes_namespace.test", "metadata.0.resource_version"),
resource.TestCheckResourceAttrSet("kubernetes_namespace.test", "metadata.0.self_link"),
resource.TestCheckResourceAttrSet("kubernetes_namespace.test", "metadata.0.uid"),
),
},
{
Config: testAccKubernetesNamespaceConfig_addAnnotations(nsName),
Check: resource.ComposeAggregateTestCheckFunc(
testAccCheckKubernetesNamespaceExists("kubernetes_namespace.test", &conf),
resource.TestCheckResourceAttr("kubernetes_namespace.test", "metadata.0.annotations.%", "2"),
Expand Down Expand Up @@ -276,6 +289,15 @@ func testAccCheckKubernetesNamespaceExists(n string, obj *api.Namespace) resourc

func testAccKubernetesNamespaceConfig_basic(nsName string) string {
return fmt.Sprintf(`
resource "kubernetes_namespace" "test" {
metadata {
name = "%s"
}
}`, nsName)
}

func testAccKubernetesNamespaceConfig_addAnnotations(nsName string) string {
return fmt.Sprintf(`
resource "kubernetes_namespace" "test" {
metadata {
annotations {
Expand All @@ -286,7 +308,6 @@ resource "kubernetes_namespace" "test" {
}
}`, nsName)
}

func testAccKubernetesNamespaceConfig_addLabels(nsName string) string {
return fmt.Sprintf(`
resource "kubernetes_namespace" "test" {
Expand Down

0 comments on commit cc09e9a

Please # to comment.