Skip to content

Commit

Permalink
Add acceptance test
Browse files Browse the repository at this point in the history
  • Loading branch information
pdecat committed Apr 18, 2018
1 parent 9f39a2c commit c2311e3
Showing 1 changed file with 47 additions and 1 deletion.
48 changes: 47 additions & 1 deletion kubernetes/resource_kubernetes_pod_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,15 @@ func TestAccKubernetesPod_basic(t *testing.T) {
resource.TestCheckResourceAttrSet("kubernetes_pod.test", "metadata.0.uid"),
resource.TestCheckResourceAttr("kubernetes_pod.test", "spec.0.container.0.env.0.value_from.0.secret_key_ref.0.name", secretName),
resource.TestCheckResourceAttr("kubernetes_pod.test", "spec.0.container.0.env.1.value_from.0.config_map_key_ref.0.name", configMapName),
resource.TestCheckResourceAttr("kubernetes_pod.test", "spec.0.container.0.env_from.#", "2"),
resource.TestCheckResourceAttr("kubernetes_pod.test", "spec.0.container.0.env_from.0.config_map_ref.#", "1"),
resource.TestCheckResourceAttr("kubernetes_pod.test", "spec.0.container.0.env_from.0.config_map_ref.0.name", fmt.Sprintf("%s-from", configMapName)),
resource.TestCheckResourceAttr("kubernetes_pod.test", "spec.0.container.0.env_from.0.config_map_ref.0.optional", "true"),
resource.TestCheckResourceAttr("kubernetes_pod.test", "spec.0.container.0.env_from.0.prefix", "FROM_CM_"),
resource.TestCheckResourceAttr("kubernetes_pod.test", "spec.0.container.0.env_from.1.secret_ref.#", "1"),
resource.TestCheckResourceAttr("kubernetes_pod.test", "spec.0.container.0.env_from.1.secret_ref.0.name", fmt.Sprintf("%s-from", secretName)),
resource.TestCheckResourceAttr("kubernetes_pod.test", "spec.0.container.0.env_from.1.secret_ref.0.optional", "false"),
resource.TestCheckResourceAttr("kubernetes_pod.test", "spec.0.container.0.env_from.1.prefix", "FROM_S_"),
resource.TestCheckResourceAttr("kubernetes_pod.test", "spec.0.container.0.image", imageName1),
),
},
Expand Down Expand Up @@ -579,6 +588,17 @@ resource "kubernetes_secret" "test" {
}
}
resource "kubernetes_secret" "test_from" {
metadata {
name = "%s-from"
}
data {
one = "first_from"
second = "second_from"
}
}
resource "kubernetes_config_map" "test" {
metadata {
name = "%s"
Expand All @@ -589,6 +609,17 @@ resource "kubernetes_config_map" "test" {
}
}
resource "kubernetes_config_map" "test_from" {
metadata {
name = "%s-from"
}
data {
one = "ONE_FROM"
two = "TWO_FROM"
}
}
resource "kubernetes_pod" "test" {
metadata {
labels {
Expand Down Expand Up @@ -624,6 +655,21 @@ resource "kubernetes_pod" "test" {
}
},
]
env_from = [{
config_map_ref {
name = "${kubernetes_config_map.test_from.metadata.0.name}"
optional = true
}
prefix = "FROM_CM_"
}, {
secret_ref {
name = "${kubernetes_secret.test_from.metadata.0.name}"
optional = false
}
prefix = "FROM_S_"
}]
}
volume {
name = "db"
Expand All @@ -633,7 +679,7 @@ resource "kubernetes_pod" "test" {
}
}
}
`, secretName, configMapName, podName, imageName)
`, secretName, secretName, configMapName, configMapName, podName, imageName)
}

func testAccKubernetesPodConfigWithSecurityContext(podName, imageName string) string {
Expand Down

0 comments on commit c2311e3

Please sign in to comment.