diff --git a/api/krusty/accumulation_test.go b/api/krusty/accumulation_test.go index 00bb7aa3a9..b5aee1ca1a 100644 --- a/api/krusty/accumulation_test.go +++ b/api/krusty/accumulation_test.go @@ -29,6 +29,20 @@ spec: - port: 7002 ` +const invalidResource = `apiVersion: v1 +kind: Service +metadata: + name: kapacitor + labels: + app.kubernetes.io/name: tick-kapacitor +spec: + selector: + app.kubernetes.io/name: tick-kapacitor + - name: http + port: 9092 + protocol: TCP + type: ClusterIP` + func TestTargetMustHaveKustomizationFile(t *testing.T) { th := kusttest_test.MakeHarness(t) th.WriteF("service.yaml", ` @@ -283,6 +297,14 @@ resources: // know resource is file. errDir: `new root '%s' cannot be absolute`, }, + { + name: "malformed yaml yields an error", + resource: "service.yaml", + files: map[string]string{ + "service.yaml": invalidResource, + }, + errFile: "MalformedYAMLError", + }, } { t.Run(test.name, func(t *testing.T) { // Should use real file system to indicate that we are creating @@ -306,5 +328,4 @@ resources: // TODO(annasong): add tests that check accumulateResources errors for // - repos // - local directories - // - files that yield malformed yaml errors }