mirror of
https://github.com/DATA-DOG/go-sqlmock.git
synced 2025-01-10 00:28:42 +02:00
closes #25
This commit is contained in:
parent
2165444c8d
commit
4bb07b88b3
33
statement_test.go
Normal file
33
statement_test.go
Normal file
@ -0,0 +1,33 @@
|
||||
package sqlmock
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"testing"
|
||||
)
|
||||
|
||||
// +build go1.6
|
||||
|
||||
func TestExpectedPreparedStatemtCloseError(t *testing.T) {
|
||||
conn, mock, err := New()
|
||||
if err != nil {
|
||||
t.Fatalf("failed to open sqlmock database:", err)
|
||||
}
|
||||
|
||||
mock.ExpectBegin()
|
||||
want := errors.New("STMT ERROR")
|
||||
mock.ExpectPrepare("SELECT").WillReturnCloseError(want)
|
||||
|
||||
txn, err := conn.Begin()
|
||||
if err != nil {
|
||||
t.Fatalf("unexpected error while opening transaction:", err)
|
||||
}
|
||||
|
||||
stmt, err := txn.Prepare("SELECT")
|
||||
if err != nil {
|
||||
t.Fatalf("unexpected error while preparing a statement:", err)
|
||||
}
|
||||
|
||||
if err := stmt.Close(); err != want {
|
||||
t.Fatalf("Got = %v, want = %v", err, want)
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user