Skip to content

Commit

Permalink
add testcase that yield malformed yaml errors
Browse files Browse the repository at this point in the history
  • Loading branch information
charles-chenzz committed Jan 8, 2024
1 parent bfb00ec commit 3f921e1
Showing 1 changed file with 22 additions and 1 deletion.
23 changes: 22 additions & 1 deletion api/krusty/accumulation_test.go
Expand Up @@ -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", `
Expand Down Expand Up @@ -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
Expand All @@ -306,5 +328,4 @@ resources:
// TODO(annasong): add tests that check accumulateResources errors for
// - repos
// - local directories
// - files that yield malformed yaml errors
}

0 comments on commit 3f921e1

Please sign in to comment.