Skip to content

Commit 81a6fa6

Browse files
committed
Add helper message to parser integration test
The parser integration test now has a better message about what to do if the output changes and how to regenerate it.
1 parent 62dae40 commit 81a6fa6

File tree

2 files changed

+24
-1
lines changed

2 files changed

+24
-1
lines changed

pkg/crd/parser_integration_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,6 @@ var _ = Describe("CRD Generation From Parsing to CustomResourceDefinition", func
8080
Expect(yaml.Unmarshal(expectedFile, &crd)).To(Succeed())
8181

8282
By("comparing the two")
83-
Expect(parser.CustomResourceDefinitions[groupKind]).To(Equal(crd), "%s", cmp.Diff(parser.CustomResourceDefinitions[groupKind], crd))
83+
Expect(parser.CustomResourceDefinitions[groupKind]).To(Equal(crd), "type not as expected, check pkg/crd/testdata/README.md for more details.\n\nDiff:\n\n%s", cmp.Diff(parser.CustomResourceDefinitions[groupKind], crd))
8484
})
8585
})

pkg/crd/testdata/README.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# CRD Integration Test testdata
2+
3+
This contains a tiny module used for testdata for the CRD integration
4+
test. The directory should always be called testdata, so Go treats it
5+
specially.
6+
7+
The `cronjob_types.go` file contains the input types, and is loosely based
8+
on the CronJob tutorial from the [KubeBuilder
9+
Book](https://book.kubebuilder.io/cronjob-tutorial.html), but with added
10+
fields to test additional markers and generation behavior.
11+
12+
If you add a new marker, re-generate the golden output file,
13+
`testdata.kubebuilder.io_cronjobs.yaml`, with:
14+
15+
```bash
16+
$ /path/to/current/build/of/controller-gen crd paths=. output:dir=.
17+
```
18+
19+
Make sure you review the diff to ensure that it only contains the desired
20+
changes!
21+
22+
If you didn't add a new marker and this output changes, make sure you have
23+
a good explanation for why generated output needs to change!

0 commit comments

Comments
 (0)