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

Unexpected behavior matching multiple identical calls

Open paulturner-resolute opened this issue 4 years ago • 0 comments
trafficstars

				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?

paulturner-resolute avatar Feb 11 '21 17:02 paulturner-resolute