pgxpoolmock
pgxpoolmock copied to clipboard
rows.go Scan() crashes after QueryRow()
When I do a QueryRow() query, the Scan() panics with this error:
index out of range [-1]
This seem to be related to this line 72:
for i, col := range r.rows[r.pos-1] {
where r.pos is 0.
you need to add Next() call
this is a simple example
columns := []string{"id"}
pgxRows := pgxpoolmock.NewRows(columns).AddRow(100).ToPgxRows()
pgxRows.Next()
suite.mockPool.EXPECT().QueryRow(gomock.Any(), `
INSERT INTO "users"("login", "password")
VALUES ($1, $2)
returning "@users"`, user.Login, user.Password).Return(pgxRows)