mirror of
https://github.com/kubernetes-sigs/kustomize.git
synced 2026-05-17 18:25:26 +00:00
Beef up test.
This commit is contained in:
@@ -75,6 +75,14 @@ func (kt *KustTarget) Load() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// Kustomization returns a copy of the immutable, internal kustomization object.
|
||||
func (kt *KustTarget) Kustomization() types.Kustomization {
|
||||
var result types.Kustomization
|
||||
b, _ := json.Marshal(*kt.kustomization)
|
||||
json.Unmarshal(b, &result)
|
||||
return result
|
||||
}
|
||||
|
||||
func loadKustFile(ldr ifc.Loader) ([]byte, error) {
|
||||
var content []byte
|
||||
match := 0
|
||||
|
||||
@@ -37,6 +37,16 @@ incididunt ut labore et dolore magna aliqua.
|
||||
Ut enim ad minim veniam, quis nostrud
|
||||
exercitation ullamco laboris nisi ut
|
||||
aliquip ex ea commodo consequat.
|
||||
`,
|
||||
},
|
||||
"commented": {
|
||||
content: `
|
||||
# Licensed to the Blah Blah Software Foundation
|
||||
# ...
|
||||
# yada yada yada.
|
||||
|
||||
commonLabels:
|
||||
app: nginx
|
||||
`,
|
||||
},
|
||||
"implicitHeader": {
|
||||
@@ -60,9 +70,6 @@ commonLabels:
|
||||
resource.NewFactory(kunstruct.NewKunstructuredFactoryImpl()))
|
||||
|
||||
for tn, tc := range testCases {
|
||||
if tn != "nonsenseLatin" {
|
||||
continue
|
||||
}
|
||||
t.Run(tn, func(t *testing.T) {
|
||||
if tc.content != "" {
|
||||
th.WriteK("/", tc.content)
|
||||
@@ -73,6 +80,13 @@ commonLabels:
|
||||
require.Contains(t, err.Error(), tc.errContains)
|
||||
} else {
|
||||
require.Nilf(t, err, "got error: %v", err)
|
||||
k := kt.Kustomization()
|
||||
require.Condition(t, func() bool {
|
||||
return len(k.CommonLabels) == 1
|
||||
}, "expecting a labels entry")
|
||||
require.Condition(t, func() bool {
|
||||
return k.CommonLabels["app"] == "nginx"
|
||||
}, "expecting app:nginx")
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user