1
0
mirror of https://github.com/zhashkevych/go-sqlxmock.git synced 2025-06-12 21:47:29 +02:00
This commit is contained in:
gedi
2016-11-02 14:49:59 +02:00
parent 05f39e9110
commit d4cd2ca2ad
4 changed files with 28 additions and 1 deletions

View File

@ -753,3 +753,23 @@ func TestEmptyRowSet(t *testing.T) {
t.Fatalf("all expectations should be met: %s", err)
}
}
// Based on issue #50
func TestPrepareExpectationNotFulfilled(t *testing.T) {
t.Parallel()
db, mock, err := New()
if err != nil {
t.Errorf("an error '%s' was not expected when opening a stub database connection", err)
}
defer db.Close()
mock.ExpectPrepare("^BADSELECT$")
if _, err := db.Prepare("SELECT"); err == nil {
t.Fatal("prepare should not match expected query string")
}
if err := mock.ExpectationsWereMet(); err == nil {
t.Errorf("was expecting an error, since prepared statement query does not match, but there was none")
}
}