Mock sql (sqlx) db on golang

I am using this library — https://pkg.go.dev/github.com/data-dog/go-sqlmock.

That’s how you can use it for mocking db querying:

That’s how you can test a function that only does the rows.StructScan, for instance:

Similar Posts

LEAVE A COMMENT