diff --git a/.travis.yml b/.travis.yml index b5e47d3..1dbfb77 100644 --- a/.travis.yml +++ b/.travis.yml @@ -8,9 +8,12 @@ go: - 1.6.x - 1.7.x - 1.8.x - - tip + # - tip # sadly fails most of thw times -script: go test -race -coverprofile=coverage.txt -covermode=atomic +script: + - go vet + - test -z "$(go fmt ./...)" # fail if not formatted properly + - go test -race -coverprofile=coverage.txt -covermode=atomic after_success: - bash <(curl -s https://codecov.io/bash) diff --git a/driver_test.go b/driver_test.go index 1a65c1c..4f805ba 100644 --- a/driver_test.go +++ b/driver_test.go @@ -109,4 +109,4 @@ func TestDuplicateNewDSN(t *testing.T) { if _, _, err := NewWithDSN("sqlmock_db_1"); err == nil { t.Error("expected error on NewWithDSN") } -} \ No newline at end of file +} diff --git a/sqlmock.go b/sqlmock.go index e3ed3e4..0f1572f 100644 --- a/sqlmock.go +++ b/sqlmock.go @@ -309,9 +309,9 @@ func (c *sqlmock) prepare(query string) (*ExpectedPrepare, error) { var expected *ExpectedPrepare var fulfilled int var ok bool - + query = stripQuery(query) - + for _, next := range c.expected { next.Lock() if next.fulfilled() { @@ -328,7 +328,7 @@ func (c *sqlmock) prepare(query string) (*ExpectedPrepare, error) { next.Unlock() return nil, fmt.Errorf("call to Prepare statement with query '%s', was not expected, next expectation is: %s", query, next) } - + if pr, ok := next.(*ExpectedPrepare); ok { if pr.sqlRegex.MatchString(query) { expected = pr diff --git a/sqlmock_test.go b/sqlmock_test.go index ffaa824..c63ced4 100644 --- a/sqlmock_test.go +++ b/sqlmock_test.go @@ -354,7 +354,6 @@ func TestPreparedQueryExecutions(t *testing.T) { } } - func TestUnorderedPreparedQueryExecutions(t *testing.T) { t.Parallel() db, mock, err := New() @@ -369,14 +368,14 @@ func TestUnorderedPreparedQueryExecutions(t *testing.T) { ExpectQuery(). WithArgs(5). WillReturnRows( - NewRows([]string{"id", "title"}).FromCSVString("5,The quick brown fox"), - ) + NewRows([]string{"id", "title"}).FromCSVString("5,The quick brown fox"), + ) mock.ExpectPrepare("SELECT (.+) FROM authors WHERE id = ?"). ExpectQuery(). WithArgs(1). WillReturnRows( - NewRows([]string{"id", "title"}).FromCSVString("1,Betty B."), - ) + NewRows([]string{"id", "title"}).FromCSVString("1,Betty B."), + ) var id int var name string