@@ -38,7 +38,6 @@ func TestHooks(t *testing.T) {
3838 type testCase struct {
3939 desc string
4040 setup func ()
41- run func (* testCase , * Manager ) error
4241 sql string
4342 req any
4443 res any
@@ -233,13 +232,6 @@ func TestHooks(t *testing.T) {
233232 HookName : `"auth"."v0hooks_test_before_user_created"` ,
234233 }
235234 },
236- run : func (tc * testCase , mr * Manager ) error {
237- return mr .BeforeUserCreated (
238- ctx , db ,
239- tc .req .(* BeforeUserCreatedInput ),
240- tc .res .(* BeforeUserCreatedOutput ),
241- )
242- },
243235 req : NewBeforeUserCreatedInput (httpReq , & models.User {}),
244236 res : & BeforeUserCreatedOutput {},
245237 exp : & BeforeUserCreatedOutput {},
@@ -262,13 +254,6 @@ func TestHooks(t *testing.T) {
262254 HookName : `"auth"."v0hooks_test_before_user_created_reject"` ,
263255 }
264256 },
265- run : func (tc * testCase , mr * Manager ) error {
266- return mr .BeforeUserCreated (
267- ctx , db ,
268- tc .req .(* BeforeUserCreatedInput ),
269- tc .res .(* BeforeUserCreatedOutput ),
270- )
271- },
272257 req : NewBeforeUserCreatedInput (httpReq , & models.User {}),
273258 res : & BeforeUserCreatedOutput {},
274259 exp : & BeforeUserCreatedOutput {Decision : "reject" },
@@ -291,13 +276,6 @@ func TestHooks(t *testing.T) {
291276 HookName : `"auth"."v0hooks_test_before_user_created_reject_msg"` ,
292277 }
293278 },
294- run : func (tc * testCase , mr * Manager ) error {
295- return mr .BeforeUserCreated (
296- ctx , db ,
297- tc .req .(* BeforeUserCreatedInput ),
298- tc .res .(* BeforeUserCreatedOutput ),
299- )
300- },
301279 req : NewBeforeUserCreatedInput (httpReq , & models.User {}),
302280 res : & BeforeUserCreatedOutput {},
303281 exp : & BeforeUserCreatedOutput {Decision : "reject" , Message : "test case" },
@@ -320,13 +298,6 @@ func TestHooks(t *testing.T) {
320298 HookName : `"auth"."v0hooks_test_after_user_created"` ,
321299 }
322300 },
323- run : func (tc * testCase , mr * Manager ) error {
324- return mr .AfterUserCreated (
325- ctx , db ,
326- tc .req .(* AfterUserCreatedInput ),
327- tc .res .(* AfterUserCreatedOutput ),
328- )
329- },
330301 req : NewAfterUserCreatedInput (httpReq , & models.User {}),
331302 res : & AfterUserCreatedOutput {},
332303 exp : & AfterUserCreatedOutput {},
@@ -437,6 +408,18 @@ func TestHooks(t *testing.T) {
437408 res : M {},
438409 errStr : "500: output should be *hooks.PasswordVerificationAttemptOutput" ,
439410 },
411+ {
412+ desc : "fail - before_user_created - invalid output type" ,
413+ req : & BeforeUserCreatedInput {},
414+ res : M {},
415+ errStr : "500: output should be *hooks.BeforeUserCreatedOutput" ,
416+ },
417+ {
418+ desc : "fail - after_user_created - invalid output type" ,
419+ req : & AfterUserCreatedInput {},
420+ res : M {},
421+ errStr : "500: output should be *hooks.AfterUserCreatedOutput" ,
422+ },
440423
441424 // fail - invalid query
442425 {
@@ -525,12 +508,7 @@ func TestHooks(t *testing.T) {
525508 }
526509
527510 htr := httptest .NewRequestWithContext (ctx , "POST" , "/api" , nil )
528- var err error
529- if tc .run == nil {
530- err = mr .InvokeHook (db , htr , tc .req , tc .res )
531- } else {
532- err = tc .run (& tc , mr )
533- }
511+ err := mr .InvokeHook (db , htr , tc .req , tc .res )
534512 if tc .errStr != "" {
535513 require .Error (t , err )
536514 require .Contains (t , err .Error (), tc .errStr )
0 commit comments