forked from go-rel/primaryreplica
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnop_adapter_test.go
74 lines (55 loc) · 1.68 KB
/
nop_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
package primaryreplica
import (
"context"
"github.com/go-rel/rel"
)
type nopAdapter struct {
retError error
}
func (na *nopAdapter) Close() error {
return na.retError
}
func (na *nopAdapter) Instrumentation(_ rel.Instrumenter) {
}
func (na *nopAdapter) Ping(_ context.Context) error {
return na.retError
}
func (na *nopAdapter) Aggregate(_ context.Context, _ rel.Query, _, _ string) (int, error) {
return 0, na.retError
}
func (na *nopAdapter) Begin(_ context.Context) (rel.Adapter, error) {
return na, na.retError
}
func (na *nopAdapter) Commit(_ context.Context) error {
return na.retError
}
func (na *nopAdapter) Delete(_ context.Context, _ rel.Query) (int, error) {
return 1, na.retError
}
func (na *nopAdapter) Insert(_ context.Context, _ rel.Query, _ string, _ map[string]rel.Mutate, _ rel.OnConflict) (interface{}, error) {
return 1, na.retError
}
func (na *nopAdapter) InsertAll(_ context.Context, _ rel.Query, _ string, _ []string, bulkMutates []map[string]rel.Mutate, _ rel.OnConflict) ([]interface{}, error) {
var (
ids = make([]interface{}, len(bulkMutates))
)
for i := range bulkMutates {
ids[i] = i + 1
}
return ids, na.retError
}
func (na *nopAdapter) Query(_ context.Context, _ rel.Query) (rel.Cursor, error) {
return nil, nil
}
func (na *nopAdapter) Rollback(_ context.Context) error {
return na.retError
}
func (na *nopAdapter) Update(_ context.Context, _ rel.Query, _ string, _ map[string]rel.Mutate) (int, error) {
return 1, na.retError
}
func (na *nopAdapter) Apply(_ context.Context, _ rel.Migration) error {
return na.retError
}
func (na *nopAdapter) Exec(_ context.Context, _ string, _ []interface{}) (int64, int64, error) {
return 0, 0, na.retError
}