Questions tagged [go-sqlmock]

sqlmock is a mock library implementing sql/driver. Which has one and only purpose - to simulate any sql driver behavior in tests, without needing a real database connection. It helps to maintain correct TDD workflow.

63 questions
0
votes
2 answers

How to test mysql insert method

I'm setting up testing in Go. I use go-sqlmock to test mysql connection. Now I try to test mysql insert logic. But the error occurs. I want to know how to resolve this error. server side: golang db: mysql web framework: gin dao.go func PostDao(db…
jpskgc.v5
  • 249
  • 1
  • 5
  • 9
-1
votes
3 answers

GORM preload causes issue while using sqlmock

GORM preload is causing this error "all expectations were already fulfilled, call to Query 'SELECT * FROM "self"."xxxxxx" WHERE "xxxxxx"."l7_code" = $1' with args [{Name: Ordinal:1 Value:9920000000054}] was not expected when I am trying to use…
-3
votes
1 answer

How to use go-sqlmock when I have concurrent query in my program?

sqlmock needs to match the SQL in order. But if I have concurrent query in my code just like this: condition1 := make(map[string]string) condition2 := make(map[string]string) var count int64 var user User var task Task var…
Mikasa JD
  • 83
  • 4
1 2 3 4
5