Skip to content

Commit

Permalink
Add test for replanning manifests which are always changing (#322)
Browse files Browse the repository at this point in the history
This adds a test for #198 and validates the fix is working (also closes
#252 and closes #279)
  • Loading branch information
gavinbunney authored Dec 3, 2024
1 parent da65ff2 commit 08f3ba7
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions kubernetes/resource_kubectl_manifest_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -956,6 +956,37 @@ YAML
})
}

func TestAccKubectlReplanAlwaysChangedYAML(t *testing.T) {
config := `
resource "kubectl_manifest" "config_map" {
yaml_body = <<EOF
apiVersion: v1
kind: ConfigMap
metadata:
name: test-cm
data:
timestamp: "${timestamp()}"
EOF
}
`
resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
CheckDestroy: testAccCheckkubectlDestroy,

Steps: []resource.TestStep{
{
Config: config,
ExpectNonEmptyPlan: true,
},
{
Config: config,
ExpectNonEmptyPlan: true,
},
},
})
}

func withAlteredField(manifest *yaml.Manifest, value interface{}, fields ...string) *yaml.Manifest {
_ = unstructured.SetNestedField(manifest.Raw.Object, value, fields...)
return manifest
Expand Down

0 comments on commit 08f3ba7

Please sign in to comment.