/
tx_mock.go
72 lines (54 loc) · 1.62 KB
/
tx_mock.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
package mocks
import (
"context"
"github.com/jackc/pgconn"
"github.com/jackc/pgx/v4"
"github.com/stretchr/testify/mock"
)
var _ pgx.Tx = (*TxMock)(nil)
type TxMock struct {
mock.Mock
}
func (tx *TxMock) Begin(ctx context.Context) (pgx.Tx, error) {
return nil, nil
}
func (tx *TxMock) BeginFunc(ctx context.Context, f func(pgx.Tx) error) (err error) {
return nil
}
func (tx *TxMock) Commit(ctx context.Context) error {
args := tx.Called(ctx)
return args.Error(0)
}
func (tx *TxMock) Rollback(ctx context.Context) error {
args := tx.Called(ctx)
return args.Error(0)
}
func (tx *TxMock) CopyFrom(ctx context.Context, tableName pgx.Identifier,
columnNames []string, rowSrc pgx.CopyFromSource) (int64, error) {
return 0, nil
}
func (tx *TxMock) SendBatch(ctx context.Context, b *pgx.Batch) pgx.BatchResults {
return nil
}
func (tx *TxMock) LargeObjects() pgx.LargeObjects {
return pgx.LargeObjects{}
}
func (tx *TxMock) Prepare(ctx context.Context, name, sql string) (*pgconn.StatementDescription, error) {
return nil, nil
}
func (tx *TxMock) Exec(ctx context.Context, sql string, arguments ...interface{}) (commandTag pgconn.CommandTag, err error) {
return nil, nil
}
func (tx *TxMock) Query(ctx context.Context, sql string, args ...interface{}) (pgx.Rows, error) {
return nil, nil
}
func (tx *TxMock) QueryRow(ctx context.Context, sql string, args ...interface{}) pgx.Row {
return nil
}
func (tx *TxMock) QueryFunc(ctx context.Context, sql string,
args []interface{}, scans []interface{}, f func(pgx.QueryFuncRow) error) (pgconn.CommandTag, error) {
return nil, nil
}
func (tx *TxMock) Conn() *pgx.Conn {
return nil
}