1
0
mirror of https://github.com/zhashkevych/go-sqlxmock.git synced 2025-11-29 21:57:41 +02:00

build query before regex, mimicking how sql.DB build their query

This commit is contained in:
Ahmad Muzakki
2017-01-15 18:57:16 +07:00
parent 947ce303a7
commit 9758862a89
3 changed files with 38 additions and 0 deletions

View File

@@ -103,3 +103,27 @@ func ExampleExpectedExec() {
fmt.Println(err)
// Output: some error
}
func TestBuildQuery(t *testing.T){
db, mock, _ := New()
query := `
SELECT
name,
email,
address,
anotherfield
FROM user
`
mock.ExpectQuery(query)
mock.ExpectExec(query)
mock.ExpectPrepare(query)
db.QueryRow(query)
db.Exec(query)
db.Prepare(query)
if err:=mock.ExpectationsWereMet(); err!=nil{
t.Error(err)
}
}