You've already forked go-sqlxmock
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:
@@ -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)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user