-
Couldn't load subscription status.
- Fork 39
Adds unit test to test CRDs #331
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
✅ Deploy Preview for kubernetes-sigs-network-policy-api ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
|
@robscott thanks for the idea |
3da3849 to
37d6d5e
Compare
|
/test |
|
@bowei: The Use In response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. |
|
/test pull-network-policy-api-verify |
|
@tssurya @npinaeva @danwinship -- any comments? |
| } | ||
| for _, e := range entries { | ||
| obj, text, err := loadYAML(validCases, path.Join(validDir, e.Name())) | ||
| if err != nil { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
somehow nit, but...
you have testify already on this repo, so maybe require.NoError(t, err) just to reduce the verbosity
(applies to all below, but instead of adding a require on the Create and delete you can do an assert so it wont leave the test)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the style recommended by the Go authors...
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: bowei The full list of commands accepted by this bot can be found here.
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nice automation!
|
I incorporated all of the comments. |
Tests the current CRDs against example valid and invalid CRDs. There
are two ways to use this:
Test cases
----------
Each test case takes its name from the name of the resource being
instantiated.
- pkg/crdtest/testdata/{valid, invalid}
Running
-------
Run as a standard Go-test:
$ go test ./pkg/crdtest
Run in -watch mode for development:
$ go test -c -o crdtest ./pkg/crdtest # or "make crdtest"
$ ./crdtest -crdDir config/crd/standard -watch pkg/crdtest/testdata/valid
will apply all yamls in pkg/crdtest/valid folder and continue watching
the changes to the *.yaml files in the folder. When a file is
changed, it will load it into an API server and print the result.
| if *watchDir != "" { | ||
| watchAndTest(*watchDir) | ||
| if testEnv != nil { | ||
| if err := testEnv.Stop(); err != nil { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
so if Stop succeeds, you will continue to m.Run() and cleaning up test env again?
maybe you can just
if *watchDir != "" {
watchAndTest(*watchDir)
rc = 0
} else {
rc = m.Run()
}
Example output for
-watch: