Skip to content

Commit

Permalink
Merge pull request #5500 from charles-chenzz/kust-target-tc
Browse files Browse the repository at this point in the history
add testcase that check yield malformed yaml errors
  • Loading branch information
k8s-ci-robot authored Apr 29, 2024
2 parents a68f407 + 3f921e1 commit e676d05
Showing 1 changed file with 22 additions and 1 deletion.
23 changes: 22 additions & 1 deletion api/krusty/accumulation_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,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 @@ -302,6 +316,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) {
if test.resourceFunc != nil {
Expand Down Expand Up @@ -338,5 +360,4 @@ resources:
// TODO(annasong): add tests that check accumulateResources errors for
// - repos
// - local directories
// - files that yield malformed yaml errors
}

0 comments on commit e676d05

Please sign in to comment.