1

I am writing test cases for a GoLang application and i am using sqlmock for mocking the SQL queries but i am getting following error while executing go test

Params: [ call to query , was not expected, next expectation is: ExpectedBegin => expecting database transaction Begin]

Any idea on this?

0

3 Answers 3

1

sqlmock expected a begin, but instead got something else. Show the function and test here for more info.

Sign up to request clarification or add additional context in comments.

Comments

0

The error message means some SQL query was called which was not mocked.

Comments

0

I had same issue, because I used NamedExec (not NamedQuery) to perform my update, but was mocking ExpectQuery in test

So,
if you have expression (i.e. use UPDATE or INSERT), you should use ExpectExec
if you have query (i.e. use SELECT), you should use ExpectQuery

It's obvious, but I stuck with it for couple of hours

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.