Skip to content

Commit

Permalink
add data source test
Browse files Browse the repository at this point in the history
  • Loading branch information
BBBmau committed Jan 25, 2025
1 parent 8ae7d7d commit 14e83d6
Showing 1 changed file with 46 additions and 0 deletions.
46 changes: 46 additions & 0 deletions helm/data_helm_template_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,24 @@ func TestAccDataTemplate_kubeVersion(t *testing.T) {
})
}

func TestAccDataTemplate_configSetNull(t *testing.T) {
name := randName("basic")
namespace := randName(testNamespacePrefix)

datasourceAddress := fmt.Sprintf("data.helm_template.%s", testResourceName)

resource.Test(t, resource.TestCase{
ProtoV6ProviderFactories: protoV6ProviderFactories(),
Steps: []resource.TestStep{{
Config: testAccDataHelmTemplateConfigNullSet(testResourceName, namespace, name, "1.2.3"),
Check: resource.ComposeAggregateTestCheckFunc(
checkResourceAttrNotSet(datasourceAddress, "set.0.value"),
checkResourceAttrNotSet(datasourceAddress, "set.1.value"),
),
}},
})
}

func testAccDataHelmTemplateConfigBasic(resource, ns, name, version string) string {
return fmt.Sprintf(`
data "helm_template" "%s" {
Expand Down Expand Up @@ -290,6 +308,34 @@ func testAccDataHelmTemplateConfigTemplates(resource, ns, name, version string)
`, resource, name, ns, testRepositoryURL, version)
}

func testAccDataHelmTemplateConfigNullSet(resource, ns, name, version string) string {
return fmt.Sprintf(`
data "helm_template" "%s" {
name = %q
namespace = %q
description = "Test"
repository = %q
chart = "test-chart"
version = %q
set = [
{
name = "foo"
},
{
name = "fizz"
value = null
}
]
show_only = [
"templates/configmaps.yaml",
""
]
}
`, resource, name, ns, testRepositoryURL, version)
}

func testAccDataHelmTemplateKubeVersion(resource, ns, name, version, kubeVersion string) string {
return fmt.Sprintf(`
data "helm_template" "%s" {
Expand Down

0 comments on commit 14e83d6

Please sign in to comment.