@@ -223,6 +223,7 @@ func TestAPIListPredicate(t *testing.T) {
223223 predicate any
224224 content []model.Model
225225 err bool
226+ errText string
226227 }{
227228 {
228229 name : "none" ,
@@ -241,8 +242,9 @@ func TestAPIListPredicate(t *testing.T) {
241242 err : false ,
242243 },
243244 {
244- name : "nil function must fail" ,
245- err : true ,
245+ name : "nil interface must fail" ,
246+ err : true ,
247+ errText : "Expected function" ,
246248 },
247249 {
248250 name : "arbitrary condition" ,
@@ -269,13 +271,27 @@ func TestAPIListPredicate(t *testing.T) {
269271 err := cond .List (context .Background (), & result )
270272 if tt .err {
271273 require .Error (t , err )
274+ if tt .errText != "" {
275+ require .ErrorContains (t , err , tt .errText )
276+ }
272277 } else {
273278 require .NoError (t , err )
274279 assert .ElementsMatchf (t , tt .content , result , "Content should match" )
275280 }
276281
277282 })
278283 }
284+
285+ t .Run ("ApiListPredicate: typed nil function must fail" , func (t * testing.T ) {
286+ var predicate func (* testLogicalSwitch ) bool
287+ var result []* testLogicalSwitch
288+ api := newAPI (tcache , & discardLogger , false )
289+ cond := api .WhereCache (predicate )
290+
291+ err := cond .List (context .Background (), & result )
292+ require .Error (t , err )
293+ require .ErrorContains (t , err , "Expected non-nil function" )
294+ })
279295}
280296
281297func TestAPIListWhereConditions (t * testing.T ) {
0 commit comments