@@ -194,8 +194,13 @@ func TestHandle(t *testing.T) {
194194 func (ctx context.Context ) CheckResult {
195195 return CheckResult {
196196 Allowed : false ,
197- Field : "spec.test" ,
198- Message : "test failed" ,
197+ Causes : []metav1.StatusCause {
198+ {
199+ Type : metav1 .CauseTypeFieldValueInvalid ,
200+ Field : "spec.test" ,
201+ Message : "test failed" ,
202+ },
203+ },
199204 }
200205 },
201206 },
@@ -239,7 +244,9 @@ func TestHandle(t *testing.T) {
239244 func (ctx context.Context ) CheckResult {
240245 return CheckResult {
241246 Allowed : true ,
242- Warning : "test warning" ,
247+ Warnings : []string {
248+ "test warning" ,
249+ },
243250 }
244251 },
245252 },
@@ -275,7 +282,13 @@ func TestHandle(t *testing.T) {
275282 return CheckResult {
276283 Allowed : false ,
277284 Error : true ,
278- Message : "internal error" ,
285+
286+ Causes : []metav1.StatusCause {
287+ {
288+ Type : metav1 .CauseTypeInternal ,
289+ Message : "internal error" ,
290+ },
291+ },
279292 }
280293 },
281294 },
@@ -285,7 +298,12 @@ func TestHandle(t *testing.T) {
285298 func (ctx context.Context ) CheckResult {
286299 return CheckResult {
287300 Allowed : false ,
288- Message : "check failed" ,
301+ Causes : []metav1.StatusCause {
302+ {
303+ Type : metav1 .CauseTypeFieldValueInvalid ,
304+ Message : "check failed" ,
305+ },
306+ },
289307 }
290308 },
291309 },
@@ -401,7 +419,12 @@ func TestHandleCancelledContext(t *testing.T) {
401419 return CheckResult {
402420 Allowed : false ,
403421 Error : true ,
404- Message : "context cancelled" ,
422+ Causes : []metav1.StatusCause {
423+ {
424+ Type : metav1 .CauseTypeInternal ,
425+ Message : "context cancelled" ,
426+ },
427+ },
405428 }
406429 case <- time .After (100 * time .Millisecond ):
407430 return CheckResult {Allowed : true }
@@ -413,7 +436,12 @@ func TestHandleCancelledContext(t *testing.T) {
413436 return CheckResult {
414437 Allowed : false ,
415438 Error : true ,
416- Message : "context cancelled" ,
439+ Causes : []metav1.StatusCause {
440+ {
441+ Type : metav1 .CauseTypeInternal ,
442+ Message : "context cancelled" ,
443+ },
444+ },
417445 }
418446 case <- time .After (100 * time .Millisecond ):
419447 return CheckResult {Allowed : true }
0 commit comments