-
-
Notifications
You must be signed in to change notification settings - Fork 67
Expand file tree
/
Copy pathsql_test.go
More file actions
31 lines (26 loc) · 547 Bytes
/
sql_test.go
File metadata and controls
31 lines (26 loc) · 547 Bytes
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
27
28
29
30
31
package pgxmock
import (
"context"
"database/sql"
"testing"
"time"
)
func TestScanTime(t *testing.T) {
mock, err := NewPool()
if err != nil {
panic(err)
}
now, _ := time.Parse(time.RFC3339, "2006-01-02T15:04:05Z07:00")
mock.ExpectQuery(`SELECT now()`).
WillReturnRows(
mock.NewRows([]string{"stamp"}).
AddRow(now))
var value sql.NullTime
err = mock.QueryRow(context.Background(), `SELECT now()`).Scan(&value)
if err != nil {
t.Error(err)
}
if value.Time != now {
t.Errorf("want %v, got %v", now, value.Time)
}
}