Closed ricirt closed 7 months ago
Hello @ricirt ,
You are getting this error because you are never actually calling db.Begin()
in the code snippet above.
Your mock database is expecting the following sequence in this exact order :
mock.ExpectBegin()
mock.ExpectExec(`insert into public."Users" ("Id", "Name", "Email") values ($1,$2,$3)`).WithArgs(user.Id, user.Name, user.Email)
mock.ExpectCommit()
So you should call a db.Begin()
then db.Exec(...)
using that exact same request.
thank you ! thats done.
Question
I'm trying mock my postgres using go-sqlmock but i'm getting this error
The method I am trying to test is adding to db users.I googled this error but couldn't something. Why i'm getting this error?