1
0
mirror of https://github.com/DATA-DOG/go-sqlmock.git synced 2025-07-03 00:36:52 +02:00

use configured QueryMatcher in order to match expected SQL to actual, closes #70

This commit is contained in:
gedi
2018-12-11 14:56:33 +02:00
parent 2a15d9c09b
commit a6e6646ad9
6 changed files with 100 additions and 65 deletions

View File

@ -3,7 +3,6 @@ package sqlmock
import (
"database/sql/driver"
"fmt"
"regexp"
"testing"
"time"
)
@ -100,20 +99,6 @@ func TestQueryExpectationArgComparisonBool(t *testing.T) {
}
}
func TestQueryExpectationSqlMatch(t *testing.T) {
e := &ExpectedExec{}
e.sqlRegex = regexp.MustCompile("SELECT x FROM")
if !e.queryMatches("SELECT x FROM someting") {
t.Errorf("Sql must have matched the query")
}
e.sqlRegex = regexp.MustCompile("SELECT COUNT\\(x\\) FROM")
if !e.queryMatches("SELECT COUNT(x) FROM someting") {
t.Errorf("Sql must have matched the query")
}
}
func ExampleExpectedExec() {
db, mock, _ := New()
result := NewErrorResult(fmt.Errorf("some error"))