-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Open
Labels
kind/bugCategorizes issue or PR as related to a bug.Categorizes issue or PR as related to a bug.needs-triageIndicates an issue or PR lacks a `triage/foo` label and requires one.Indicates an issue or PR lacks a `triage/foo` label and requires one.
Description
What happened?
In api/krusty/openapicustomschema_test.go, there are many tests which changes OpenAPI schema. So, it has
test helper function runOpenApiTest
to reset OpenAPI to its default, as
func runOpenApiTest(t *testing.T, test func(t *testing.T)) { t.Helper() openapi.ResetOpenAPI() test(t) openapi.ResetOpenAPI() }
but 2nd openapi.ResetOpenAPI()
won't be called if the test(t)
failed.
So, if there are any test failures which change OpenAPI schema, other tests depending on any OpenAPI schema (, including built-in one) may fail.
What did you expect to happen?
Any test failures within api/krusty/openapicustomschema_test.go shouldn't affect other tests.
How can we reproduce it (as minimally and precisely as possible)?
- Make one of test in api/krusty/openapicustomschema_test.go, e.g.
TestCustomOpenApiFieldWithoutMergePatchExtension
fail. - Run that test and other tests in the same session, e.g.
cd api go test -v -run '^(TestCustomOpenApi|TestPatchDeleteOfNotExistingAttributesShouldNotAddExtraElements)' ./krusty
Unrelated test TestPatchDeleteOfNotExistingAttributesShouldNotAddExtraElements
(defined in api/krusty/patchdelete_test.go) will fail.
Expected output
=== RUN TestPatchDeleteOfNotExistingAttributesShouldNotAddExtraElements
--- PASS: TestPatchDeleteOfNotExistingAttributesShouldNotAddExtraElements
Actual output
=== RUN TestPatchDeleteOfNotExistingAttributesShouldNotAddExtraElements
===== ACTUAL BEGIN ========================================
apiVersion: apps/v1
kind: Deployment
metadata:
name: whatever
spec:
template:
spec:
containers:
- env:
- $patch: delete
name: FOR_REMOVAL
- $patch: delete
name: NOT_EXISTING_FOR_REMOVAL
name: whatever
===== ACTUAL END ==========================================
EXPECTED ACTUAL
-------- ------
apiVersion: apps/v1 apiVersion: apps/v1
kind: Deployment kind: Deployment
metadata: metadata:
name: whatever name: whatever
spec: spec:
template: template:
spec: spec:
containers: containers:
- env: - env:
X - name: EXISTING - $patch: delete
X value: EXISTING_VALUE name: FOR_REMOVAL
X image: helloworld - $patch: delete
X name: whatever name: NOT_EXISTING_FOR_REMOVAL
X name: whatever
hasgett.go:22: Expected not equal to actual
--- FAIL: TestPatchDeleteOfNotExistingAttributesShouldNotAddExtraElements (0.00s)
Kustomize version
master branch
Operating system
MacOS
Metadata
Metadata
Assignees
Labels
kind/bugCategorizes issue or PR as related to a bug.Categorizes issue or PR as related to a bug.needs-triageIndicates an issue or PR lacks a `triage/foo` label and requires one.Indicates an issue or PR lacks a `triage/foo` label and requires one.