1
2
3
4
5
6
7
8
9
10
11
12
13 package mock
14
15 import (
16 "context"
17
18 "github.com/go-kivik/kivik/v4/driver"
19 )
20
21
22 type Client struct {
23
24 ID string
25 AllDBsFunc func(context.Context, driver.Options) ([]string, error)
26 CreateDBFunc func(context.Context, string, driver.Options) error
27 DBFunc func(string, driver.Options) (driver.DB, error)
28 DBExistsFunc func(context.Context, string, driver.Options) (bool, error)
29 DestroyDBFunc func(context.Context, string, driver.Options) error
30 VersionFunc func(context.Context) (*driver.Version, error)
31 }
32
33 var _ driver.Client = &Client{}
34
35
36 func (c *Client) AllDBs(ctx context.Context, opts driver.Options) ([]string, error) {
37 return c.AllDBsFunc(ctx, opts)
38 }
39
40
41 func (c *Client) CreateDB(ctx context.Context, dbname string, opts driver.Options) error {
42 return c.CreateDBFunc(ctx, dbname, opts)
43 }
44
45
46 func (c *Client) DB(dbname string, opts driver.Options) (driver.DB, error) {
47 return c.DBFunc(dbname, opts)
48 }
49
50
51 func (c *Client) DBExists(ctx context.Context, dbname string, opts driver.Options) (bool, error) {
52 return c.DBExistsFunc(ctx, dbname, opts)
53 }
54
55
56 func (c *Client) DestroyDB(ctx context.Context, dbname string, opts driver.Options) error {
57 return c.DestroyDBFunc(ctx, dbname, opts)
58 }
59
60
61 func (c *Client) Version(ctx context.Context) (*driver.Version, error) {
62 return c.VersionFunc(ctx)
63 }
64
65
66 type ClientReplicator struct {
67 *Client
68 GetReplicationsFunc func(context.Context, driver.Options) ([]driver.Replication, error)
69 ReplicateFunc func(context.Context, string, string, driver.Options) (driver.Replication, error)
70 }
71
72 var _ driver.ClientReplicator = &ClientReplicator{}
73
74
75 func (c *ClientReplicator) GetReplications(ctx context.Context, opts driver.Options) ([]driver.Replication, error) {
76 return c.GetReplicationsFunc(ctx, opts)
77 }
78
79
80 func (c *ClientReplicator) Replicate(ctx context.Context, target, source string, opts driver.Options) (driver.Replication, error) {
81 return c.ReplicateFunc(ctx, target, source, opts)
82 }
83
84
85 type DBUpdater struct {
86 *Client
87 DBUpdatesFunc func(context.Context, driver.Options) (driver.DBUpdates, error)
88 }
89
90 var _ driver.DBUpdater = &DBUpdater{}
91
92
93 func (c *DBUpdater) DBUpdates(ctx context.Context, options driver.Options) (driver.DBUpdates, error) {
94 return c.DBUpdatesFunc(ctx, options)
95 }
96
97
98 type DBsStatser struct {
99 *Client
100 DBsStatsFunc func(context.Context, []string) ([]*driver.DBStats, error)
101 }
102
103 var _ driver.DBsStatser = &DBsStatser{}
104
105
106 func (c *DBsStatser) DBsStats(ctx context.Context, dbnames []string) ([]*driver.DBStats, error) {
107 return c.DBsStatsFunc(ctx, dbnames)
108 }
109
110
111 type Pinger struct {
112 *Client
113 PingFunc func(context.Context) (bool, error)
114 }
115
116 var _ driver.Pinger = &Pinger{}
117
118
119 func (c *Pinger) Ping(ctx context.Context) (bool, error) {
120 return c.PingFunc(ctx)
121 }
122
123
124 type Cluster struct {
125 *Client
126 ClusterStatusFunc func(context.Context, driver.Options) (string, error)
127 ClusterSetupFunc func(context.Context, interface{}) error
128 MembershipFunc func(context.Context) (*driver.ClusterMembership, error)
129 }
130
131 var _ driver.Cluster = &Cluster{}
132
133
134 func (c *Cluster) ClusterStatus(ctx context.Context, options driver.Options) (string, error) {
135 return c.ClusterStatusFunc(ctx, options)
136 }
137
138
139 func (c *Cluster) ClusterSetup(ctx context.Context, action interface{}) error {
140 return c.ClusterSetupFunc(ctx, action)
141 }
142
143
144 func (c *Cluster) Membership(ctx context.Context) (*driver.ClusterMembership, error) {
145 return c.MembershipFunc(ctx)
146 }
147
148
149 type ClientCloser struct {
150 *Client
151 CloseFunc func() error
152 }
153
154 var _ driver.ClientCloser = &ClientCloser{}
155
156
157 func (c *ClientCloser) Close() error {
158 return c.CloseFunc()
159 }
160
161
162 type Configer struct {
163 *Client
164 ConfigFunc func(context.Context, string) (driver.Config, error)
165 ConfigSectionFunc func(context.Context, string, string) (driver.ConfigSection, error)
166 ConfigValueFunc func(context.Context, string, string, string) (string, error)
167 SetConfigValueFunc func(context.Context, string, string, string, string) (string, error)
168 DeleteConfigKeyFunc func(context.Context, string, string, string) (string, error)
169 }
170
171 var _ driver.Configer = &Configer{}
172
173
174 func (c *Configer) Config(ctx context.Context, node string) (driver.Config, error) {
175 return c.ConfigFunc(ctx, node)
176 }
177
178
179 func (c *Configer) ConfigSection(ctx context.Context, node, section string) (driver.ConfigSection, error) {
180 return c.ConfigSectionFunc(ctx, node, section)
181 }
182
183
184 func (c *Configer) ConfigValue(ctx context.Context, node, section, key string) (string, error) {
185 return c.ConfigValueFunc(ctx, node, section, key)
186 }
187
188
189 func (c *Configer) SetConfigValue(ctx context.Context, node, section, key, value string) (string, error) {
190 return c.SetConfigValueFunc(ctx, node, section, key, value)
191 }
192
193
194 func (c *Configer) DeleteConfigKey(ctx context.Context, node, section, key string) (string, error) {
195 return c.DeleteConfigKeyFunc(ctx, node, section, key)
196 }
197
View as plain text