go-sqlmock icon indicating copy to clipboard operation
go-sqlmock copied to clipboard

How mock sql many times?

Open a1499418300 opened this issue 5 years ago • 1 comments
trafficstars

  • Hello, when I exec one sql many times, I got the error: --- FAIL: TestMysqlProxy_getItemByID (0.00s) --- FAIL: TestMysqlProxy_getItemByID/getItemByID_OK (0.00s) main_test.go:49: err: all expectations were already fulfilled, call to Query 'SELECT id, name FROM user where id = ?' with args [{Name: Ordinal:1 Value:1}] was not expected, got: {ID:0 Name:} main_test.go:51: MysqlProxy.getItemByID() error = all expectations were already fulfilled, call to Query 'SELECT id, name FROM user where id = ?' with args [{Name: Ordinal:1 Value:1}] was not expected, wantErr false

  • my code image

  • unit test code image

a1499418300 avatar Oct 21 '20 07:10 a1499418300

maybe #257 can help you

yashschandra avatar Mar 11 '21 23:03 yashschandra