mirror of
https://github.com/kubernetes/kubernetes.git
synced 2026-06-08 16:30:57 -04:00
Make sure errors present in declarative validation test files are DV errors
This commit is contained in:
parent
1dde6f3475
commit
c3fecccd3e
1 changed files with 8 additions and 1 deletions
|
|
@ -282,7 +282,7 @@ func verifyValidationEquivalence(t *testing.T, expectedErrs field.ErrorList, run
|
|||
var imperativeErrs field.ErrorList
|
||||
|
||||
// The errOutputMatcher is used to verify the output matches the expected errors in test cases.
|
||||
errOutputMatcher := field.ErrorMatcher{}.ByType().ByOrigin().ByFieldNormalized(opt.NormalizationRules)
|
||||
errOutputMatcher := field.ErrorMatcher{}.ByType().ByOrigin().ByFieldNormalized(opt.NormalizationRules).ByDeclarativeNative()
|
||||
|
||||
// We only need to test both gate enabled and disabled together, because
|
||||
// 1) the DeclarativeValidationTakeover won't take effect if DeclarativeValidation is disabled.
|
||||
|
|
@ -299,6 +299,13 @@ func verifyValidationEquivalence(t *testing.T, expectedErrs field.ErrorList, run
|
|||
} else if len(declarativeTakeoverErrs) != 0 {
|
||||
t.Errorf("expected no errors, but got: %v", declarativeTakeoverErrs)
|
||||
}
|
||||
|
||||
// make sure all errors marked by covered by declarative validations, are actually covered.
|
||||
for _, err := range declarativeTakeoverErrs {
|
||||
if err.CoveredByDeclarative {
|
||||
t.Errorf("error %v should be covered by declarative validation", err)
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
t.Run("hand written validation", func(t *testing.T) {
|
||||
|
|
|
|||
Loading…
Reference in a new issue