mirror of
https://github.com/kubernetes-sigs/kustomize.git
synced 2026-06-13 10:00:56 +00:00
add regression tests for multiline configmap with space
This commit is contained in:
@@ -572,3 +572,71 @@ metadata:
|
||||
name: test-k9cc55dfm5
|
||||
`)
|
||||
}
|
||||
|
||||
// regression test for https://github.com/kubernetes-sigs/kustomize/issues/4287
|
||||
func TestMultilineDataEndsWithSpace(t *testing.T) {
|
||||
th := kusttest_test.MakeHarness(t)
|
||||
th.WriteK(".", `
|
||||
apiVersion: kustomize.config.k8s.io/v1beta1
|
||||
kind: Kustomization
|
||||
configMapGenerator:
|
||||
- name: config_bla
|
||||
files:
|
||||
- cfg.text=cfg.text
|
||||
`)
|
||||
th.WriteF("cfg.text", `bla
|
||||
bla
|
||||
bla
|
||||
`)
|
||||
|
||||
m := th.Run(".", th.MakeDefaultOptions())
|
||||
th.AssertActualEqualsExpected(
|
||||
m, `apiVersion: v1
|
||||
data:
|
||||
cfg.text: "bla\nbla\nbla \n"
|
||||
kind: ConfigMap
|
||||
metadata:
|
||||
name: config_bla-d6m295b8c5
|
||||
`)
|
||||
}
|
||||
|
||||
// regression test to record the behavior prior to the fix for https://github.com/kubernetes-sigs/kustomize/issues/4287
|
||||
// so that the fix does not affect leading and trailing newlines in ConfigMap data
|
||||
func TestMultilineDataEndsLeadingAndTrailingNewlines(t *testing.T) {
|
||||
th := kusttest_test.MakeHarness(t)
|
||||
th.WriteK(".", `
|
||||
apiVersion: kustomize.config.k8s.io/v1beta1
|
||||
kind: Kustomization
|
||||
configMapGenerator:
|
||||
- name: config_bla
|
||||
files:
|
||||
- cfg.text=cfg.text
|
||||
`)
|
||||
th.WriteF("cfg.text", `
|
||||
|
||||
bla
|
||||
bla
|
||||
bla
|
||||
|
||||
|
||||
|
||||
`)
|
||||
|
||||
m := th.Run(".", th.MakeDefaultOptions())
|
||||
th.AssertActualEqualsExpected(
|
||||
m, `apiVersion: v1
|
||||
data:
|
||||
cfg.text: |2+
|
||||
|
||||
|
||||
bla
|
||||
bla
|
||||
bla
|
||||
|
||||
|
||||
|
||||
kind: ConfigMap
|
||||
metadata:
|
||||
name: config_bla-8dm6c68g22
|
||||
`)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user