mirror of
https://github.com/zhashkevych/go-sqlxmock.git
synced 2024-11-24 08:12:13 +02:00
related to sql escaping #14
This commit is contained in:
parent
5b6166bfbf
commit
e163520142
@ -7,6 +7,26 @@ import (
|
||||
"time"
|
||||
)
|
||||
|
||||
func TestIssue14EscapeSQL(t *testing.T) {
|
||||
db, err := New()
|
||||
if err != nil {
|
||||
t.Errorf("an error '%s' was not expected when opening a stub database connection", err)
|
||||
}
|
||||
ExpectExec("INSERT INTO mytable\\(a, b\\)").
|
||||
WithArgs("A", "B").
|
||||
WillReturnResult(NewResult(1, 1))
|
||||
|
||||
_, err = db.Exec("INSERT INTO mytable(a, b) VALUES (?, ?)", "A", "B")
|
||||
if err != nil {
|
||||
t.Errorf("error '%s' was not expected, while inserting a row", err)
|
||||
}
|
||||
|
||||
err = db.Close()
|
||||
if err != nil {
|
||||
t.Errorf("error '%s' was not expected while closing the database", err)
|
||||
}
|
||||
}
|
||||
|
||||
// test the case when db is not triggered and expectations
|
||||
// are not asserted on close
|
||||
func TestIssue4(t *testing.T) {
|
||||
|
Loading…
Reference in New Issue
Block a user