-
-
Notifications
You must be signed in to change notification settings - Fork 404
Description
Question
This is the actual code:
err = c.database.QueryRowContext(ctx, "SELECT COUNT(*) FROM user_credentials WHERE user_id = $1", passwordUpdateRequest.UserId).Scan(&count)
This is mock:
suite.dbMock.ExpectQuery(SELECT COUNT(*) FROM user_credentials WHERE user_id = ?).
WithArgs(tc.userID).
WillReturnRows(suite.dbMock.NewRows([]string{"count"}).AddRow(1))
When its run, this error occurs:
failed to check user credentials: Query: error parsing regexp: missing argument to repetition operator: *
When the * is escaped,
failed to check user credentials: Query: could not match actual sql: "SELECT COUNT(*) FROM user_credentials WHERE user_id = $1" with expected regexp "SELECT COUNT(*) FROM user_credentials WHERE user_id = ?"
So it seems there's no way of satisfying this, I tried many other escape methods as well but they all cause the second error.