DATA-DOG / go-sqlmock

Sql mock driver for golang to test database interactions
Other
6.16k stars 407 forks source link

Unexpected behavior matching multiple identical calls #253

Closed paulturner-resolute closed 5 months ago

paulturner-resolute commented 3 years ago
                db, mock, err := sqlmock.New()
                is.NoErr(err)
                rowSet := sqlmock.
                    NewRows([]string{"col1", "col2", "col3"}).
                    AddRow("expected", "result", "set")
                mock.ExpectQuery(selectSQL).
                    WithArgs("1").
                    WillReturnRows(rowSet).
                    WillReturnError(errors.New("some error"))

I expected this to return my result set the first time it is called and then return the error the second and subsequent times it is called (like Mockito does), but it just returns the error consistently. Is setting expectations like that possible?

diegommm commented 5 months ago

Hi @paulturner-resolute! Closing as there is not enough information to help you, unfortunately. If the problem persists, reopen and provide the following information:

Thank you!