diff --git a/expecter.go b/expecter.go index f6153c84..ebe36269 100644 --- a/expecter.go +++ b/expecter.go @@ -4,6 +4,7 @@ import ( "database/sql" "errors" "fmt" + "regexp" ) type Recorder struct { @@ -116,8 +117,8 @@ func (h *Expecter) AssertExpectations() error { // First triggers a Query func (h *Expecter) First(out interface{}, where ...interface{}) ExpectedQuery { - h.gorm.First(out, where) - return h.adapter.ExpectQuery(h.recorder.stmt) + h.gorm.First(out) + return h.adapter.ExpectQuery(regexp.QuoteMeta(h.recorder.stmt)) } // Find triggers a Query diff --git a/expecter_test.go b/expecter_test.go index edef7e06..c93bd06f 100644 --- a/expecter_test.go +++ b/expecter_test.go @@ -39,8 +39,9 @@ func TestQuery(t *testing.T) { } expect.First(&User{}) - db.First(&User{}) - expect.AssertExpectations() + if err := expect.AssertExpectations(); err != nil { + t.Error(err) + } }