-
Notifications
You must be signed in to change notification settings - Fork 76
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
migrating to a better request/response test model
trying to improve tests and fix a panic in prometheus counter labels trying to get admissionresponse tests in shape working up a better test for request/response got patch diffing working clarify patch diffing fix up request/response model to be more expressive reformat where patch tests are on the FS add unit test docs remove unneeded bit
- Loading branch information
Showing
15 changed files
with
274 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
# Unit Tests | ||
|
||
To add a new unit test for some behavior, please do the following: | ||
|
||
1. create a AdmissionRequest in YAML format at `test/fixtures/k8s/admissioncontrol/request/foo.yaml`. This should include the pod spec k8s will send with the request, and the annotation with the desired injected sidecar | ||
2. create a Patch JSON at `test/fixtures/k8s/admissioncontrol/patch/foo.json`. | ||
3. register your test in the `pkg/server/webhook_test.go` list `mutationTests` | ||
|
||
Please use the `injector.unittest.com/request` annotation on your `AdmissionRequest` YAML to signal which sidecar you want to be injected. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 23 additions & 0 deletions
23
test/fixtures/k8s/admissioncontrol/patch/env-override.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
[ | ||
{ | ||
"op": "add", | ||
"path": "/spec/containers/0/env/-", | ||
"value": { | ||
"name": "FOO_BAR", | ||
"value": "something interesting" | ||
} | ||
}, | ||
{ | ||
"path": "/spec/containers/0/env/-", | ||
"value": { | ||
"name": "ENVIRONMENT", | ||
"value": "production" | ||
}, | ||
"op": "add" | ||
}, | ||
{ | ||
"op": "add", | ||
"path": "/metadata/annotations/injector.unittest.com~1status", | ||
"value": "injected" | ||
} | ||
] |
Oops, something went wrong.