mirror of
https://github.com/kyverno/kyverno.git
synced 2025-04-08 18:15:48 +00:00
fix: adding verbosity to openapi unit tests (#6580)
Signed-off-by: Ankit152 <ankitkurmi152@gmail.com> Co-authored-by: Charles-Edouard Brétéché <charles.edouard@nirmata.com>
This commit is contained in:
parent
cdf79daa44
commit
f8b352ff55
1 changed files with 18 additions and 14 deletions
|
@ -76,18 +76,20 @@ func Test_ValidateMutationPolicy(t *testing.T) {
|
|||
o, _ := NewManager(logr.Discard())
|
||||
|
||||
for i, tc := range tcs {
|
||||
policy := v1.ClusterPolicy{}
|
||||
_ = json.Unmarshal(tc.policy, &policy)
|
||||
var errMessage string
|
||||
err := o.ValidatePolicyMutation(&policy)
|
||||
if err != nil {
|
||||
errMessage = err.Error()
|
||||
}
|
||||
if tc.mustSucceed {
|
||||
assert.NilError(t, err, "\nTestcase [%v] failed: Expected no error, Got error: %v", i+1, errMessage)
|
||||
} else {
|
||||
assert.Assert(t, err != nil, "\nTestcase [%v] failed: Expected error to have occurred", i+1)
|
||||
}
|
||||
t.Run(tc.description, func(t *testing.T) {
|
||||
policy := v1.ClusterPolicy{}
|
||||
_ = json.Unmarshal(tc.policy, &policy)
|
||||
var errMessage string
|
||||
err := o.ValidatePolicyMutation(&policy)
|
||||
if err != nil {
|
||||
errMessage = err.Error()
|
||||
}
|
||||
if tc.mustSucceed {
|
||||
assert.NilError(t, err, "\nTestcase [%v] failed: Expected no error, Got error: %v", i+1, errMessage)
|
||||
} else {
|
||||
assert.Assert(t, err != nil, "\nTestcase [%v] failed: Expected error to have occurred", i+1)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -187,8 +189,10 @@ func Test_matchGVK(t *testing.T) {
|
|||
}
|
||||
|
||||
for i, test := range testCases {
|
||||
res := matchGVK(test.definitionName, test.gvk)
|
||||
assert.Equal(t, res, test.match, "test #%d failed", i)
|
||||
t.Run(test.definitionName, func(t *testing.T) {
|
||||
res := matchGVK(test.definitionName, test.gvk)
|
||||
assert.Equal(t, res, test.match, "test #%d failed", i)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue