|
| 1 | +package kubernetes |
| 2 | + |
| 3 | +import ( |
| 4 | + "fmt" |
| 5 | + "testing" |
| 6 | + |
| 7 | + "github.com/hashicorp/terraform-plugin-sdk/helper/acctest" |
| 8 | + "github.com/hashicorp/terraform-plugin-sdk/helper/resource" |
| 9 | +) |
| 10 | + |
| 11 | +func TestAccKubernetesDataSourceConfigMap_basic(t *testing.T) { |
| 12 | + name := fmt.Sprintf("tf-acc-test-%s", acctest.RandStringFromCharSet(10, acctest.CharSetAlphaNum)) |
| 13 | + |
| 14 | + resource.Test(t, resource.TestCase{ |
| 15 | + PreCheck: func() { testAccPreCheck(t) }, |
| 16 | + Providers: testAccProviders, |
| 17 | + Steps: []resource.TestStep{ |
| 18 | + { |
| 19 | + Config: testAccKubernetesDataSourceConfigMapConfig_basic(name), |
| 20 | + Check: resource.ComposeAggregateTestCheckFunc( |
| 21 | + resource.TestCheckResourceAttr("data.kubernetes_config_map.test", "metadata.0.name", name), |
| 22 | + resource.TestCheckResourceAttrSet("data.kubernetes_config_map.test", "metadata.0.generation"), |
| 23 | + resource.TestCheckResourceAttrSet("data.kubernetes_config_map.test", "metadata.0.resource_version"), |
| 24 | + resource.TestCheckResourceAttrSet("data.kubernetes_config_map.test", "metadata.0.self_link"), |
| 25 | + resource.TestCheckResourceAttrSet("data.kubernetes_config_map.test", "metadata.0.uid"), |
| 26 | + resource.TestCheckResourceAttr("data.kubernetes_config_map.test", "metadata.0.annotations.%", "2"), |
| 27 | + resource.TestCheckResourceAttr("data.kubernetes_config_map.test", "metadata.0.annotations.TestAnnotationOne", "one"), |
| 28 | + resource.TestCheckResourceAttr("data.kubernetes_config_map.test", "metadata.0.annotations.TestAnnotationTwo", "two"), |
| 29 | + resource.TestCheckResourceAttr("data.kubernetes_config_map.test", "metadata.0.labels.TestLabelOne", "one"), |
| 30 | + resource.TestCheckResourceAttr("data.kubernetes_config_map.test", "metadata.0.labels.TestLabelTwo", "two"), |
| 31 | + resource.TestCheckResourceAttr("data.kubernetes_config_map.test", "metadata.0.labels.TestLabelThree", "three"), |
| 32 | + resource.TestCheckResourceAttr("data.kubernetes_config_map.test", "data.%", "2"), |
| 33 | + resource.TestCheckResourceAttr("data.kubernetes_config_map.test", "data.one", "first"), |
| 34 | + resource.TestCheckResourceAttr("data.kubernetes_config_map.test", "data.two", "second"), |
| 35 | + ), |
| 36 | + }, |
| 37 | + }, |
| 38 | + }) |
| 39 | +} |
| 40 | + |
| 41 | +func testAccKubernetesDataSourceConfigMapConfig_basic(name string) string { |
| 42 | + return testAccKubernetesConfigMapConfig_basic(name) + ` |
| 43 | +data "kubernetes_config_map" "test" { |
| 44 | + metadata { |
| 45 | + name = "${kubernetes_config_map.test.metadata.0.name}" |
| 46 | + } |
| 47 | +} |
| 48 | +` |
| 49 | +} |
0 commit comments