Skip to content

Commit

Permalink
test bug 1085 with service account
Browse files Browse the repository at this point in the history
  • Loading branch information
dak1n1 committed Dec 17, 2020
1 parent c6da541 commit f7e3cf7
Showing 1 changed file with 16 additions and 5 deletions.
21 changes: 16 additions & 5 deletions kubernetes/resource_kubernetes_pod_test.go
Expand Up @@ -904,14 +904,18 @@ func TestAccKubernetesPod_bug1085(t *testing.T) {
CheckDestroy: testAccCheckKubernetesPodDestroy,
Steps: []resource.TestStep{
{
Config: testAccKubernetesPodConfigWithVolume(name, imageName),
Config: testAccKubernetesPodConfigWithVolume(name, imageName, ""),
Check: resource.ComposeAggregateTestCheckFunc(
testAccCheckKubernetesPodExists("kubernetes_pod.test", &conf),
resource.TestCheckResourceAttr("kubernetes_pod.test", "spec.0.service_account_name", "default"),
),
},
{
Config: testAccKubernetesPodConfigWithVolume(name, imageName),
PlanOnly: true,
Config: testAccKubernetesPodConfigWithVolume(name, imageName, `service_account_name="test"`),
Check: resource.ComposeAggregateTestCheckFunc(
testAccCheckKubernetesPodExists("kubernetes_pod.test", &conf),
resource.TestCheckResourceAttr("kubernetes_pod.test", "spec.0.service_account_name", "test"),
),
},
},
})
Expand Down Expand Up @@ -2418,14 +2422,20 @@ func testAccKubernetesPodConfigEmptyBlocks(name, imageName string) string {
`, name, imageName)
}

func testAccKubernetesPodConfigWithVolume(name, imageName string) string {
func testAccKubernetesPodConfigWithVolume(name, imageName, serviceAccount string) string {
return fmt.Sprintf(`resource "kubernetes_storage_class" "test" {
metadata {
name = "test"
}
storage_provisioner = "k8s.io/minikube-hostpath"
}
resource "kubernetes_service_account" "test" {
metadata {
name = "test"
}
}
resource "kubernetes_persistent_volume" "test" {
metadata {
name = "test"
Expand Down Expand Up @@ -2467,6 +2477,7 @@ resource "kubernetes_pod" "test" {
name = "%s"
}
spec {
%s
container {
name = "default"
image = "%s"
Expand All @@ -2484,5 +2495,5 @@ resource "kubernetes_pod" "test" {
}
}
}
`, name, imageName)
`, name, serviceAccount, imageName)
}

0 comments on commit f7e3cf7

Please sign in to comment.