/
client.go
191 lines (151 loc) · 6.13 KB
/
client.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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
package mock
import (
"context"
"github.com/go-kivik/kivik/v3/driver"
)
// Client mocks driver.Client
type Client struct {
// ID identifies a specific Client instance
ID string
AllDBsFunc func(context.Context, map[string]interface{}) ([]string, error)
CreateDBFunc func(context.Context, string, map[string]interface{}) error
DBFunc func(context.Context, string, map[string]interface{}) (driver.DB, error)
DBExistsFunc func(context.Context, string, map[string]interface{}) (bool, error)
DestroyDBFunc func(context.Context, string, map[string]interface{}) error
VersionFunc func(context.Context) (*driver.Version, error)
}
var _ driver.Client = &Client{}
// AllDBs calls c.AllDBsFunc
func (c *Client) AllDBs(ctx context.Context, opts map[string]interface{}) ([]string, error) {
return c.AllDBsFunc(ctx, opts)
}
// CreateDB calls c.CreateDBFunc
func (c *Client) CreateDB(ctx context.Context, dbname string, opts map[string]interface{}) error {
return c.CreateDBFunc(ctx, dbname, opts)
}
// DB calls c.DBFunc
func (c *Client) DB(ctx context.Context, dbname string, opts map[string]interface{}) (driver.DB, error) {
return c.DBFunc(ctx, dbname, opts)
}
// DBExists calls c.DBExistsFunc
func (c *Client) DBExists(ctx context.Context, dbname string, opts map[string]interface{}) (bool, error) {
return c.DBExistsFunc(ctx, dbname, opts)
}
// DestroyDB calls c.DestroyDBFunc
func (c *Client) DestroyDB(ctx context.Context, dbname string, opts map[string]interface{}) error {
return c.DestroyDBFunc(ctx, dbname, opts)
}
// Version calls c.VersionFunc
func (c *Client) Version(ctx context.Context) (*driver.Version, error) {
return c.VersionFunc(ctx)
}
// ClientReplicator mocks driver.Client and driver.ClientReplicator
type ClientReplicator struct {
*Client
GetReplicationsFunc func(context.Context, map[string]interface{}) ([]driver.Replication, error)
ReplicateFunc func(context.Context, string, string, map[string]interface{}) (driver.Replication, error)
}
var _ driver.ClientReplicator = &ClientReplicator{}
// GetReplications calls c.GetReplicationsFunc
func (c *ClientReplicator) GetReplications(ctx context.Context, opts map[string]interface{}) ([]driver.Replication, error) {
return c.GetReplicationsFunc(ctx, opts)
}
// Replicate calls c.ReplicateFunc
func (c *ClientReplicator) Replicate(ctx context.Context, target, source string, opts map[string]interface{}) (driver.Replication, error) {
return c.ReplicateFunc(ctx, target, source, opts)
}
// Authenticator mocks driver.Client and driver.Authenticator
type Authenticator struct {
*Client
AuthenticateFunc func(context.Context, interface{}) error
}
var _ driver.Authenticator = &Authenticator{}
// Authenticate calls c.AuthenticateFunc
func (c *Authenticator) Authenticate(ctx context.Context, a interface{}) error {
return c.AuthenticateFunc(ctx, a)
}
// DBUpdater mocks driver.Client and driver.DBUpdater
type DBUpdater struct {
*Client
DBUpdatesFunc func(context.Context) (driver.DBUpdates, error)
}
var _ driver.DBUpdater = &DBUpdater{}
// DBUpdates calls c.DBUpdatesFunc
func (c *DBUpdater) DBUpdates(ctx context.Context) (driver.DBUpdates, error) {
return c.DBUpdatesFunc(ctx)
}
// DBsStatser mocks driver.Client and driver.DBsStatser
type DBsStatser struct {
*Client
DBsStatsFunc func(context.Context, []string) ([]*driver.DBStats, error)
}
var _ driver.DBsStatser = &DBsStatser{}
// DBsStats calls c.DBsStatsFunc
func (c *DBsStatser) DBsStats(ctx context.Context, dbnames []string) ([]*driver.DBStats, error) {
return c.DBsStatsFunc(ctx, dbnames)
}
// Pinger mocks driver.Client and driver.Pinger
type Pinger struct {
*Client
PingFunc func(context.Context) (bool, error)
}
var _ driver.Pinger = &Pinger{}
// Ping calls c.PingFunc
func (c *Pinger) Ping(ctx context.Context) (bool, error) {
return c.PingFunc(ctx)
}
// Cluster mocks driver.Client and driver.Cluster
type Cluster struct {
*Client
ClusterStatusFunc func(context.Context, map[string]interface{}) (string, error)
ClusterSetupFunc func(context.Context, interface{}) error
}
var _ driver.Cluster = &Cluster{}
// ClusterStatus calls c.ClusterStatusFunc
func (c *Cluster) ClusterStatus(ctx context.Context, options map[string]interface{}) (string, error) {
return c.ClusterStatusFunc(ctx, options)
}
// ClusterSetup calls c.ClusterSetupFunc
func (c *Cluster) ClusterSetup(ctx context.Context, action interface{}) error {
return c.ClusterSetupFunc(ctx, action)
}
// ClientCloser mocks driver.Client and driver.ClientCloser
type ClientCloser struct {
*Client
CloseFunc func(context.Context) error
}
var _ driver.ClientCloser = &ClientCloser{}
// Close calls c.CloseFunc
func (c *ClientCloser) Close(ctx context.Context) error {
return c.CloseFunc(ctx)
}
// Configer mocks driver.Client and driver.Configer
type Configer struct {
*Client
ConfigFunc func(context.Context, string) (driver.Config, error)
ConfigSectionFunc func(context.Context, string, string) (driver.ConfigSection, error)
ConfigValueFunc func(context.Context, string, string, string) (string, error)
SetConfigValueFunc func(context.Context, string, string, string, string) (string, error)
DeleteConfigKeyFunc func(context.Context, string, string, string) (string, error)
}
var _ driver.Configer = &Configer{}
// Config calls c.ConfigFunc
func (c *Configer) Config(ctx context.Context, node string) (driver.Config, error) {
return c.ConfigFunc(ctx, node)
}
// ConfigSection calls c.ConfSectionFunc
func (c *Configer) ConfigSection(ctx context.Context, node, section string) (driver.ConfigSection, error) {
return c.ConfigSectionFunc(ctx, node, section)
}
// ConfigValue calls c.ConfigValueFunc
func (c *Configer) ConfigValue(ctx context.Context, node, section, key string) (string, error) {
return c.ConfigValueFunc(ctx, node, section, key)
}
// SetConfigValue calls c.SetConfigValueFunc
func (c *Configer) SetConfigValue(ctx context.Context, node, section, key, value string) (string, error) {
return c.SetConfigValueFunc(ctx, node, section, key, value)
}
// DeleteConfigKey calls c.DeleteConfigKeyFunc
func (c *Configer) DeleteConfigKey(ctx context.Context, node, section, key string) (string, error) {
return c.DeleteConfigKeyFunc(ctx, node, section, key)
}