-
-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathpgx_test.go
57 lines (44 loc) · 1.19 KB
/
pgx_test.go
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
package postgres
import (
"testing"
"time"
"github.com/go-rel/rel"
"github.com/stretchr/testify/assert"
_ "github.com/jackc/pgx/v5/stdlib"
)
func init() {
// hack to make sure location it has the same location object as returned by pgx driver.
time.Local, _ = time.LoadLocation("Asia/Jakarta")
}
func TestAdapterPgx_specs(t *testing.T) {
driverName = "pgx"
adapter := MustOpen(dsn())
defer adapter.Close()
repo := rel.New(adapter)
AdapterSpecs(t, repo)
}
func TestAdapterPgx_Transaction_commitError(t *testing.T) {
driverName = "pgx"
adapter := MustOpen(dsn())
defer adapter.Close()
assert.NotNil(t, adapter.Commit(ctx))
}
func TestAdapterPgx_Transaction_rollbackError(t *testing.T) {
driverName = "pgx"
adapter := MustOpen(dsn())
defer adapter.Close()
assert.NotNil(t, adapter.Rollback(ctx))
}
func TestAdapterPgx_Exec_error(t *testing.T) {
driverName = "pgx"
adapter := MustOpen(dsn())
defer adapter.Close()
_, _, err := adapter.Exec(ctx, "error", nil)
assert.NotNil(t, err)
}
func TestAdapterPgx_InvalidDriverPanic(t *testing.T) {
assert.Panics(t, func() {
driverName = "pgx/v4"
MustOpen("postgres://test:test@localhost:1111/test?sslmode=disable&timezone=Asia/Jakarta")
})
}