You've already forked go-sqlmock
mirror of
https://github.com/DATA-DOG/go-sqlmock.git
synced 2025-07-17 01:22:23 +02:00
Add ExpectPing to watch for db Ping calls
This commit is contained in:
26
sqlmock_before_go18_test.go
Normal file
26
sqlmock_before_go18_test.go
Normal file
@ -0,0 +1,26 @@
|
||||
// +build !go1.8
|
||||
|
||||
package sqlmock
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"testing"
|
||||
"time"
|
||||
)
|
||||
|
||||
func TestSqlmockExpectPingHasNoEffect(t *testing.T) {
|
||||
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()
|
||||
|
||||
e := mock.ExpectPing()
|
||||
|
||||
// Methods on the expectation can be called
|
||||
e.WillDelayFor(time.Hour).WillReturnError(fmt.Errorf("an error"))
|
||||
|
||||
if err = mock.ExpectationsWereMet(); err != nil {
|
||||
t.Errorf("expected no error to be returned, but got '%s'", err)
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user