mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-29 22:46:12 +00:00
Use origin in validateFalse's own test
This commit is contained in:
parent
d1d77cd553
commit
4c0c2d21ea
@ -30,6 +30,6 @@ func FixedResult[T any](_ context.Context, op operation.Operation, fldPath *fiel
|
||||
return nil
|
||||
}
|
||||
return field.ErrorList{
|
||||
field.Invalid(fldPath, value, "forced failure: "+arg),
|
||||
field.Invalid(fldPath, value, "forced failure: "+arg).WithOrigin("validateFalse"),
|
||||
}
|
||||
}
|
||||
|
@ -121,6 +121,7 @@ func TestFixedResult(t *testing.T) {
|
||||
pass: true,
|
||||
}}
|
||||
|
||||
matcher := field.ErrorMatcher{}.ByOrigin().ByDetailExact()
|
||||
for i, tc := range cases {
|
||||
result := FixedResult(context.Background(), operation.Operation{}, field.NewPath("fldpath"), tc.value, nil, tc.pass, "detail string")
|
||||
if len(result) != 0 && tc.pass {
|
||||
@ -136,9 +137,10 @@ func TestFixedResult(t *testing.T) {
|
||||
t.Errorf("case %d: unexepected multi-error: %v", i, fmtErrs(result))
|
||||
continue
|
||||
}
|
||||
if want, got := "forced failure: detail string", result[0].Detail; got != want {
|
||||
t.Errorf("case %d: wrong error, expected: %q, got: %q", i, want, got)
|
||||
wantErrorList := field.ErrorList{
|
||||
field.Invalid(field.NewPath("fldpath"), tc.value, "forced failure: detail string").WithOrigin("validateFalse"),
|
||||
}
|
||||
matcher.Test(t, wantErrorList, result)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user