-
Notifications
You must be signed in to change notification settings - Fork 36
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
WithReply values getting interchanged during tests #7
Comments
still haven't been able to figure this out, added debugging logs to the test and func, on some occasion rows.Columns() swaps the order of how they should be returned by the query & reply adding test logs with debugs below: `•••••2018/10/21 14:05:26 Mock Reply: [map[in_review:1 ineligible:2]] [2018-10-21 14:05:26] [0.05ms] SELECT COALESCE(sum(case when app.status in('SUBMITTED','REQUIRES_ACTION') then 1 else 0 end),0) as in_review, COALESCE(sum(case when app.status = 'INELIGIBLE' then 1 else 0 end),0) as ineligible FROM application as app WHERE (app.id in(select employee.id from employee where employee.cs_id in('1a'))) • Failure [0.001 seconds] Expected |
Hi @jaylane, let me take look into. I will get back to you as soon as possible. |
@Selvatico I also encountered this problem. |
I am having the same issue. I am trying to mock replies for two SELECT queries, one count(*) and the other selecting columns (using sql QueryContext and rows.Next() / rows.Scan()). Half of the time the responses get swapped and the test fails. |
I am also having the same issue. |
I have since switched to: https://github.com/DATA-DOG/go-sqlmock . Appreciate the work put into go-mocket but the Datadog library has much better support. |
any movement on this? @saurori does the datadog package support gorm? |
@jaylane I'm wondering if go-mocket is looking at how the fields are returned by the DB driver. In your SELECT statement - you're aliasing the InReview field Can you try modifying your mock reply as such: |
My tests are passing half of the time and failing half of the time when using go-mocket mock and a response struct.
example test:
failure:
func & struct being tested:
half of the time the test passes fine, the other half it fails because InReview and Ineligible values are swapped. I've been banging my head against the wall with it for a week now. any help would be greatly appreciated. Seems to be happening anytime I'm using a response struct or there is > 1 column on the WithReply. Thanks for a great mocking package btw.
The text was updated successfully, but these errors were encountered: