-
-
Notifications
You must be signed in to change notification settings - Fork 57
/
Copy pathadapter_test.go
97 lines (76 loc) · 2.53 KB
/
adapter_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
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
94
95
96
97
package rel
import (
"context"
"github.com/stretchr/testify/mock"
)
type testAdapter struct {
mock.Mock
result any
}
var _ Adapter = (*testAdapter)(nil)
func (ta *testAdapter) Open(dsn string) error {
args := ta.Called(dsn)
return args.Error(0)
}
func (ta *testAdapter) Close() error {
args := ta.Called()
return args.Error(0)
}
func (ta *testAdapter) Instrumentation(instrumenter Instrumenter) {
}
func (ta *testAdapter) Ping(ctx context.Context) error {
args := ta.Called()
return args.Error(0)
}
func (ta *testAdapter) Aggregate(ctx context.Context, query Query, aggregate string, field string) (int, error) {
args := ta.Called(query, aggregate, field)
return args.Int(0), args.Error(1)
}
func (ta *testAdapter) Query(ctx context.Context, query Query) (Cursor, error) {
args := ta.Called(query)
return args.Get(0).(Cursor), args.Error(1)
}
func (ta *testAdapter) Insert(ctx context.Context, query Query, primaryField string, mutates map[string]Mutate, onConflict OnConflict) (any, error) {
args := ta.Called(query, mutates, onConflict)
return args.Get(0), args.Error(1)
}
func (ta *testAdapter) InsertAll(ctx context.Context, query Query, primaryField string, fields []string, mutates []map[string]Mutate, onConflict OnConflict) ([]any, error) {
args := ta.Called(query, fields, mutates, onConflict)
return args.Get(0).([]any), args.Error(1)
}
func (ta *testAdapter) Update(ctx context.Context, query Query, primaryField string, mutates map[string]Mutate) (int, error) {
args := ta.Called(query, primaryField, mutates)
return args.Int(0), args.Error(1)
}
func (ta *testAdapter) Delete(ctx context.Context, query Query) (int, error) {
args := ta.Called(query)
return args.Int(0), args.Error(1)
}
func (ta *testAdapter) Begin(ctx context.Context) (Adapter, error) {
args := ta.Called()
return ta, args.Error(0)
}
func (ta *testAdapter) Commit(ctx context.Context) error {
args := ta.Called()
return args.Error(0)
}
func (ta *testAdapter) Rollback(ctx context.Context) error {
args := ta.Called()
return args.Error(0)
}
func (ta *testAdapter) Apply(ctx context.Context, migration Migration) error {
args := ta.Called(migration)
return args.Error(0)
}
func (ta *testAdapter) Result(result any) *testAdapter {
ta.result = result
return ta
}
func (ta *testAdapter) Exec(ctx context.Context, stmt string, args []any) (int64, int64, error) {
mockArgs := ta.Called(ctx, stmt, args)
return int64(mockArgs.Int(0)), int64(mockArgs.Int(1)), mockArgs.Error(2)
}
func (ta *testAdapter) Name() string {
args := ta.Called()
return args.String(0)
}