This is the Error I'm getting
all expectations were already fulfilled, call to database transaction Begin was not expected
I have a code in my go lang
var userRoles models.UserRole
userRoles.UserID = userID
userRoles.RoleID = id
db.Create(&userRoles)
And This Query is generated
INSERT INTO user_roles (user_id,role_id,created_at,updated_at) VALUES (1,1,2020-05-08 13:35:59,2020-05-08 13:35:59)
While mocking with this code with WithArgs() and Without WithArgs()
mock.ExpectBegin()
mock.ExpectExec("INSERT INTO \"u").WithArgs(1, 1, sqlmock.AnyArg(), sqlmock.AnyArg()).WillReturnResult(sqlmock.NewResult(1, 1))
mock.ExpectCommit()
I have also tried this
mock.ExpectQuery("INSERT INTO user.*").WithArgs(1,1,sqlmock.AnyArg()sqlmock.AnyArg()).WillReturnRows(row)
Getting same error
This is the Error I'm getting
all expectations were already fulfilled, call to database transaction Begin was not expected
I have a code in my go lang
And This Query is generated
INSERT INTO user_roles (user_id,role_id,created_at,updated_at) VALUES (1,1,2020-05-08 13:35:59,2020-05-08 13:35:59)
While mocking with this code withWithArgs()
andWithout WithArgs()
I have also tried this
mock.ExpectQuery("INSERT INTO user.*").WithArgs(1,1,sqlmock.AnyArg()sqlmock.AnyArg()).WillReturnRows(row)
Getting same error