You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
A new funcionality with ExpectBatch() function doesn`t match Batch() expectation, when we are trying to follow expectations without straight order using pgxmock.MatchExpectationsInOrder(false).
To Reproduce
funcprocessBatch(db pgxmock.PgxPoolIface) error {
batch:=&pgx.Batch{}
// Random orderbatch.Queue("SELECT id FROM normalized_queries WHERE query = $1", "some query")
batch.Queue("INSERT INTO normalized_queries (query) VALUES ($1) RETURNING id", "some query")
results:=db.SendBatch(context.Background(), batch)
deferresults.Close()
fori:=0; i<batch.Len(); i++ {
varidinterr:=results.QueryRow().Scan(&id)
iferr!=nil {
returnerr
}
}
returnnil
}
funcTestProcessBatch(t*testing.T) {
mock, err:=pgxmock.NewPool()
assert.NoError(t, err)
defermock.Close()
mock.MatchExpectationsInOrder(false)
expectedBatch:=mock.ExpectBatch()
expectedBatch.ExpectQuery(regexp.QuoteMeta("INSERT INTO normalized_queries (query) VALUES ($1) RETURNING id")).WithArgs("some query").
WillReturnRows(pgxmock.NewRows([]string{"id"}).AddRow(10))
expectedBatch.ExpectQuery(regexp.QuoteMeta("SELECT id FROM normalized_queries WHERE query = $1")).WithArgs("some query").
WillReturnRows(pgxmock.NewRows([]string{"id"}).AddRow(20))
err=processBatch(mock)
assert.NoError(t, err)
assert.NoError(t, mock.ExpectationsWereMet())
}
Describe the bug
A new funcionality with ExpectBatch() function doesn`t match Batch() expectation, when we are trying to follow expectations without straight order using pgxmock.MatchExpectationsInOrder(false).
To Reproduce
Screenshot of the issue
Expected behavior
Screenshot of the expected behaviour
Desktop:
The text was updated successfully, but these errors were encountered: