1
0
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:
Matthew Huxtable
2019-11-04 18:02:04 +00:00
parent e64ef33e8b
commit dd0fe2afd6
7 changed files with 329 additions and 5 deletions

View 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)
}
}