@@ -19,12 +19,22 @@ type testHooks struct {
1919 onError ErrorHook
2020}
2121
22- func (h * testHooks ) noop () {
23- noop := func (ctx context.Context , query string , args ... interface {}) (context.Context , error ) {
22+ func newTestHooks () * testHooks {
23+ th := & testHooks {}
24+ th .reset ()
25+ return th
26+ }
27+
28+ func (h * testHooks ) reset () {
29+ noop := func (ctx context.Context , _ string , _ ... interface {}) (context.Context , error ) {
2430 return ctx , nil
2531 }
2632
27- h .before , h .after = noop , noop
33+ noopErr := func (_ context.Context , err error , _ string , _ ... interface {}) error {
34+ return err
35+ }
36+
37+ h .before , h .after , h .onError = noop , noop , noopErr
2838}
2939
3040func (h * testHooks ) Before (ctx context.Context , query string , args ... interface {}) (context.Context , error ) {
@@ -45,7 +55,8 @@ type suite struct {
4555}
4656
4757func newSuite (t * testing.T , driver driver.Driver , dsn string ) * suite {
48- hooks := & testHooks {}
58+ hooks := newTestHooks ()
59+
4960 driverName := fmt .Sprintf ("sqlhooks-%s" , time .Now ().String ())
5061 sql .Register (driverName , Wrap (driver , hooks ))
5162
0 commit comments