File tree Expand file tree Collapse file tree 1 file changed +33
-0
lines changed
Expand file tree Collapse file tree 1 file changed +33
-0
lines changed Original file line number Diff line number Diff line change 1+ package sqlmock
2+
3+ import (
4+ "errors"
5+ "testing"
6+ )
7+
8+ // +build go1.6
9+
10+ func TestExpectedPreparedStatemtCloseError (t * testing.T ) {
11+ conn , mock , err := New ()
12+ if err != nil {
13+ t .Fatalf ("failed to open sqlmock database:" , err )
14+ }
15+
16+ mock .ExpectBegin ()
17+ want := errors .New ("STMT ERROR" )
18+ mock .ExpectPrepare ("SELECT" ).WillReturnCloseError (want )
19+
20+ txn , err := conn .Begin ()
21+ if err != nil {
22+ t .Fatalf ("unexpected error while opening transaction:" , err )
23+ }
24+
25+ stmt , err := txn .Prepare ("SELECT" )
26+ if err != nil {
27+ t .Fatalf ("unexpected error while preparing a statement:" , err )
28+ }
29+
30+ if err := stmt .Close (); err != want {
31+ t .Fatalf ("Got = %v, want = %v" , err , want )
32+ }
33+ }
You can’t perform that action at this time.
0 commit comments