-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmock-postgresr.go
93 lines (73 loc) · 2.29 KB
/
mock-postgresr.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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
package postgresr
import (
"context"
"github.com/jackc/pgconn"
"github.com/jackc/pgproto3/v2"
"github.com/jackc/pgx/v4"
)
type MockConn struct {
CloseFunc func(ctx context.Context) error
ExecFunc func(ctx context.Context, sql string, arguments ...interface{}) (pgconn.CommandTag, error)
PingFunc func(ctx context.Context) error
QueryFunc func(ctx context.Context, sql string, args ...interface{}) (pgx.Rows, error)
QueryRowFunc func(ctx context.Context, sql string, args ...interface{}) pgx.Row
}
type MockRows struct {
CloseFunc func()
CommandTagFunc func() pgconn.CommandTag
ErrFunc func() error
FieldDescriptionsFunc func() []pgproto3.FieldDescription
GetTotalRowsFunc func() uint64
NextFunc func() bool
ScanFunc func(dest ...interface{}) error
ValuesFunc func() ([]interface{}, error)
RawValuesFunc func() [][]byte
}
type MockRow struct {
ScanFunc func(dest ...interface{}) error
}
func (m *MockConn) Close(ctx context.Context) error {
return m.CloseFunc(ctx)
}
func (m *MockConn) Exec(ctx context.Context, sql string, arguments ...interface{}) (pgconn.CommandTag, error) {
return m.ExecFunc(ctx, sql, arguments...)
}
func (m *MockConn) Ping(ctx context.Context) error {
return m.PingFunc(ctx)
}
func (m *MockConn) Query(ctx context.Context, sql string, args ...interface{}) (pgx.Rows, error) {
return m.QueryFunc(ctx, sql, args...)
}
func (m *MockConn) QueryRow(ctx context.Context, sql string, args ...interface{}) pgx.Row {
return m.QueryRowFunc(ctx, sql, args...)
}
func (m *MockRows) Close() {
m.CloseFunc()
}
func (m *MockRows) CommandTag() pgconn.CommandTag {
return m.CommandTagFunc()
}
func (m *MockRows) Err() error {
return m.ErrFunc()
}
func (m *MockRows) FieldDescriptions() []pgproto3.FieldDescription {
return m.FieldDescriptionsFunc()
}
func (m *MockRows) GetTotalRows() uint64 {
return m.GetTotalRowsFunc()
}
func (m *MockRows) Next() bool {
return m.NextFunc()
}
func (m *MockRows) Scan(dest ...interface{}) error {
return m.ScanFunc(dest...)
}
func (m *MockRows) Values() ([]interface{}, error) {
return m.ValuesFunc()
}
func (m *MockRows) RawValues() [][]byte {
return m.RawValuesFunc()
}
func (m *MockRow) Scan(dest ...interface{}) error {
return m.ScanFunc(dest...)
}