File: sqlmock_before_go18_test.go

package info (click to toggle)
golang-github-data-dog-go-sqlmock 1.4.1-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye, forky, sid, trixie
  • size: 352 kB
  • sloc: makefile: 3
file content (26 lines) | stat: -rw-r--r-- 540 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
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)
	}
}