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

QueryRowContext support

Open sheepman-x opened this issue 5 years ago • 1 comments
trafficstars

mycode

m.ExpectQuery("select name from t").WithArgs(1, 2)
db.QueryRow("select name from t where id in ? limit 1", []int{1, 2})
if err := m.ExpectationsWereMet(); err != nil {
	t.Errorf("there were unfulfilled expectations: %s", err)
}

i got

there were unfulfilled expectations: there is a remaining expectation which was not matched: ExpectedQuery => expecting Query, QueryContext or QueryRow which:
              - matches sql: 'select name from t'
              - is with arguments:
                0 - 1
                1 - 2

Query, QueryContext or QueryRow no QueryRowContext

sheepman-x avatar Sep 22 '20 12:09 sheepman-x

Firstly, sqlmocks support QueryRowContext, this is an example: https://go.dev/play/p/ExJZSW3TLDb Secondly, you do it in a wrong, this is a corret way: https://go.dev/play/p/Rucz0hKBNc3

Maybe the error message is misinformation

fatelei avatar Jul 30 '22 11:07 fatelei