mirror of
https://github.com/kubernetes-sigs/kustomize.git
synced 2026-06-10 08:20:59 +00:00
Merge pull request #3382 from monopole/emptyMapMania
Isolate tests related to #3396
This commit is contained in:
@@ -307,7 +307,7 @@ metadata:
|
||||
`)
|
||||
}
|
||||
|
||||
// This serie of constants is used to prove the need of
|
||||
// This series of constants is used to prove the need of
|
||||
// the namespace field in the objref field of the var declaration.
|
||||
// The following tests demonstrate that it creates umbiguous variable
|
||||
// declaration if two entities of the kind with the same name
|
||||
@@ -472,10 +472,12 @@ spec:
|
||||
// not specified
|
||||
func TestVariablesAmbiguous(t *testing.T) {
|
||||
th := kusttest_test.MakeHarness(t)
|
||||
th.WriteK("/namespaceNeedInVar/myapp", namespaceNeedInVarMyApp)
|
||||
th.WriteF("/namespaceNeedInVar/myapp/elasticsearch-dev-service.yaml", namespaceNeedInVarDevResources)
|
||||
th.WriteF("/namespaceNeedInVar/myapp/elasticsearch-test-service.yaml", namespaceNeedInVarTestResources)
|
||||
err := th.RunWithErr("/namespaceNeedInVar/myapp", th.MakeDefaultOptions())
|
||||
th.WriteK(".", namespaceNeedInVarMyApp)
|
||||
th.WriteF("elasticsearch-dev-service.yaml",
|
||||
namespaceNeedInVarDevResources)
|
||||
th.WriteF("elasticsearch-test-service.yaml",
|
||||
namespaceNeedInVarTestResources)
|
||||
err := th.RunWithErr(".", th.MakeDefaultOptions())
|
||||
if err == nil {
|
||||
t.Fatalf("expected error")
|
||||
}
|
||||
@@ -529,16 +531,20 @@ vars:
|
||||
// and resources into multiple kustomization context/folders instead of one.
|
||||
func TestVariablesAmbiguousWorkaround(t *testing.T) {
|
||||
th := kusttest_test.MakeHarness(t)
|
||||
th.WriteK("/namespaceNeedInVar/dev", namespaceNeedInVarDevFolder)
|
||||
th.WriteF("/namespaceNeedInVar/dev/elasticsearch-dev-service.yaml", namespaceNeedInVarDevResources)
|
||||
th.WriteK("/namespaceNeedInVar/test", namespaceNeedInVarTestFolder)
|
||||
th.WriteF("/namespaceNeedInVar/test/elasticsearch-test-service.yaml", namespaceNeedInVarTestResources)
|
||||
th.WriteK("/namespaceNeedInVar/workaround", `
|
||||
opts := th.MakeDefaultOptions()
|
||||
if opts.UseKyaml {
|
||||
t.Skip("TODO(#3396)")
|
||||
}
|
||||
th.WriteK("dev", namespaceNeedInVarDevFolder)
|
||||
th.WriteF("dev/elasticsearch-dev-service.yaml", namespaceNeedInVarDevResources)
|
||||
th.WriteK("test", namespaceNeedInVarTestFolder)
|
||||
th.WriteF("test/elasticsearch-test-service.yaml", namespaceNeedInVarTestResources)
|
||||
th.WriteK("workaround", `
|
||||
resources:
|
||||
- ../dev
|
||||
- ../test
|
||||
`)
|
||||
m := th.Run("/namespaceNeedInVar/workaround", th.MakeDefaultOptions())
|
||||
m := th.Run("workaround", opts)
|
||||
th.AssertActualEqualsExpected(m, namespaceNeedInVarExpectedOutput)
|
||||
}
|
||||
|
||||
@@ -585,9 +591,13 @@ vars:
|
||||
// to the variable declarations allows to disambiguate the variables.
|
||||
func TestVariablesDisambiguatedWithNamespace(t *testing.T) {
|
||||
th := kusttest_test.MakeHarness(t)
|
||||
th.WriteK("/namespaceNeedInVar/myapp", namespaceNeedInVarMyAppWithNamespace)
|
||||
th.WriteF("/namespaceNeedInVar/myapp/elasticsearch-dev-service.yaml", namespaceNeedInVarDevResources)
|
||||
th.WriteF("/namespaceNeedInVar/myapp/elasticsearch-test-service.yaml", namespaceNeedInVarTestResources)
|
||||
m := th.Run("/namespaceNeedInVar/myapp", th.MakeDefaultOptions())
|
||||
opts := th.MakeDefaultOptions()
|
||||
if opts.UseKyaml {
|
||||
t.Skip("TODO(#3396)")
|
||||
}
|
||||
th.WriteK(".", namespaceNeedInVarMyAppWithNamespace)
|
||||
th.WriteF("elasticsearch-dev-service.yaml", namespaceNeedInVarDevResources)
|
||||
th.WriteF("elasticsearch-test-service.yaml", namespaceNeedInVarTestResources)
|
||||
m := th.Run(".", th.MakeDefaultOptions())
|
||||
th.AssertActualEqualsExpected(m, namespaceNeedInVarExpectedOutput)
|
||||
}
|
||||
|
||||
@@ -362,6 +362,10 @@ resources:
|
||||
|
||||
func TestVarRefBig(t *testing.T) {
|
||||
th := kusttest_test.MakeHarness(t)
|
||||
opts := th.MakeDefaultOptions()
|
||||
if opts.UseKyaml {
|
||||
t.Skip("TODO(#3396)")
|
||||
}
|
||||
th.WriteK("/app/base", `
|
||||
namePrefix: base-
|
||||
resources:
|
||||
@@ -678,7 +682,7 @@ namePrefix: dev-
|
||||
resources:
|
||||
- ../../base
|
||||
`)
|
||||
m := th.Run("/app/overlay/staging", th.MakeDefaultOptions())
|
||||
m := th.Run("/app/overlay/staging", opts)
|
||||
th.AssertActualEqualsExpected(m, `
|
||||
apiVersion: v1
|
||||
kind: ServiceAccount
|
||||
|
||||
Reference in New Issue
Block a user