go-sqlmock
go-sqlmock copied to clipboard
Sql mock driver for golang to test database interactions
Hi!, I've the following update: ````go ret := r.db.Exec(regexp.QuoteMeta("UPDATE $1 SET Counter = Counter + $2 RETURNING Counter + 1"), "COUTERS", n) var c int ret.Scan(&c) ```` The test has:...
I have to test one function where there is a call to a procedure like this ``` if err = DB.WithContext(ctx).Raw("call x_get_number_by_id( ?)", id).Scan(&n).Error; err != nil { return n,...
added a fix in sqlmock Prepared stmt expectations building to avoid re-addition of same query to the common sqlmock expectation list. While executing mock prepare(), this will allow to consider...
Hi there, Hope you are well today. Great work done here, really appreciated! Wondering if you could possibly add an example about how to implement it in GORM? I found...
### Issue Description Hi... I'm facing an issue in my Go application when using `go-sqlmock` for unit testing my database interactions. The problem arises when trying to simulate a row...
**Description**: I'm trying to mock a database query that returns rows containing a column of type `[]string` (analogous to PostgreSQL's `text[]` field). However, even after implementing a custom `ValueConverter` to...
### Operating system and Go Version Mac OS Ventura 13.4 ### Issue Json Byte does not consistently match for every run ### Reproduction steps TBD #### Expected Result Always matches...
It would be really handy if `sqlmock.ExpectBegin()` allowed the user to verify the options passed to `BeginTx()`. ### Proposal - add `txOptions *TxOptions` field to `ExpectedBegin`: https://github.com/DATA-DOG/go-sqlmock/blob/3476f31d8fc4d652040f8d534380f5b54a8d3a42/expectations.go#L54 - set `ExpectedBegin.txOptions`...
The addition of the resultset logic caused a nil pointer dereference panic whenever nil is used as an input. This is a WIP PR. I intend to add a unit...