Beef up test.

This commit is contained in:
jregan
2020-05-19 18:26:18 -07:00
parent 33d72e9ae6
commit 07b679955e
2 changed files with 25 additions and 3 deletions

View File

@@ -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

View File

@@ -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")
}
})
}