Skip to content

v1.0.3

Compare
Choose a tag to compare
@dzhahaiev dzhahaiev released this 21 Jun 13:08
· 31 commits to master since this release

Support of any error type to be mocked as a result

WithError allows to set an error to any matched query.
For example

functionality_test.go
...
// in tests you write following
Mock.NewMock().WithQuery(`SELECT * FROM "campaign"`).WithError(sql.ErrNoRows) 
// rest part of test
...


functionality.go
...
// in order to be able to test following functionality in your code
if err:=DB.Find(&a, Campaign{UUID: uuid}).Error; err == sql.ErrNoRows {
 //some code here
}
...