-
-
Notifications
You must be signed in to change notification settings - Fork 406
Closed
Description
Question
Hello, I have a test for an app using both sqlmock and GORM:
db.ExpectPrepare(regexp.QuoteMeta(`INSERT INTO "table_name").
ExpectQuery().
WithArgs(testId, anotherTestId).
WillReturnRows(sqlmock.NewRows([]string{"test_id", "another_test_id"}).
AddRow(testId, anotherTestId))
However, when I run my tests, sometimes the query I receive is like this:
INSERT INTO "table_name" ("test_id","another_test_id") VALUES ('example','example2') ON CONFLICT DO NOTHING RETURNING "test_id","another_test_id"
And other times, the arguments are swapped like this:
INSERT INTO "table_name" ("another_test_id", "test_id") VALUES ('example','example2') ON CONFLICT DO NOTHING RETURNING "test_id","another_test_id"
This inconsistency in the order of arguments causes some tests to fail because sqlmock expects the query arguments in a specific order. I would like to know if there is a way to make sqlmock not care about the order of arguments. Thank you.
Metadata
Metadata
Assignees
Labels
No labels