github.com/projecteru2/core@v0.0.0-20240321043226-06bcc1c23f58/store/etcdv3/meta/mocks/KV.go (about) 1 // Code generated by mockery v2.31.4. DO NOT EDIT. 2 3 package mocks 4 5 import ( 6 context "context" 7 8 clientv3 "go.etcd.io/etcd/client/v3" 9 10 lock "github.com/projecteru2/core/lock" 11 12 mock "github.com/stretchr/testify/mock" 13 14 mvccpb "go.etcd.io/etcd/api/v3/mvccpb" 15 16 time "time" 17 ) 18 19 // KV is an autogenerated mock type for the KV type 20 type KV struct { 21 mock.Mock 22 } 23 24 // BatchCreate provides a mock function with given fields: ctx, data, opts 25 func (_m *KV) BatchCreate(ctx context.Context, data map[string]string, opts ...clientv3.OpOption) (*clientv3.TxnResponse, error) { 26 _va := make([]interface{}, len(opts)) 27 for _i := range opts { 28 _va[_i] = opts[_i] 29 } 30 var _ca []interface{} 31 _ca = append(_ca, ctx, data) 32 _ca = append(_ca, _va...) 33 ret := _m.Called(_ca...) 34 35 var r0 *clientv3.TxnResponse 36 var r1 error 37 if rf, ok := ret.Get(0).(func(context.Context, map[string]string, ...clientv3.OpOption) (*clientv3.TxnResponse, error)); ok { 38 return rf(ctx, data, opts...) 39 } 40 if rf, ok := ret.Get(0).(func(context.Context, map[string]string, ...clientv3.OpOption) *clientv3.TxnResponse); ok { 41 r0 = rf(ctx, data, opts...) 42 } else { 43 if ret.Get(0) != nil { 44 r0 = ret.Get(0).(*clientv3.TxnResponse) 45 } 46 } 47 48 if rf, ok := ret.Get(1).(func(context.Context, map[string]string, ...clientv3.OpOption) error); ok { 49 r1 = rf(ctx, data, opts...) 50 } else { 51 r1 = ret.Error(1) 52 } 53 54 return r0, r1 55 } 56 57 // BatchCreateAndDecr provides a mock function with given fields: ctx, data, decrKey 58 func (_m *KV) BatchCreateAndDecr(ctx context.Context, data map[string]string, decrKey string) error { 59 ret := _m.Called(ctx, data, decrKey) 60 61 var r0 error 62 if rf, ok := ret.Get(0).(func(context.Context, map[string]string, string) error); ok { 63 r0 = rf(ctx, data, decrKey) 64 } else { 65 r0 = ret.Error(0) 66 } 67 68 return r0 69 } 70 71 // BatchDelete provides a mock function with given fields: ctx, keys, opts 72 func (_m *KV) BatchDelete(ctx context.Context, keys []string, opts ...clientv3.OpOption) (*clientv3.TxnResponse, error) { 73 _va := make([]interface{}, len(opts)) 74 for _i := range opts { 75 _va[_i] = opts[_i] 76 } 77 var _ca []interface{} 78 _ca = append(_ca, ctx, keys) 79 _ca = append(_ca, _va...) 80 ret := _m.Called(_ca...) 81 82 var r0 *clientv3.TxnResponse 83 var r1 error 84 if rf, ok := ret.Get(0).(func(context.Context, []string, ...clientv3.OpOption) (*clientv3.TxnResponse, error)); ok { 85 return rf(ctx, keys, opts...) 86 } 87 if rf, ok := ret.Get(0).(func(context.Context, []string, ...clientv3.OpOption) *clientv3.TxnResponse); ok { 88 r0 = rf(ctx, keys, opts...) 89 } else { 90 if ret.Get(0) != nil { 91 r0 = ret.Get(0).(*clientv3.TxnResponse) 92 } 93 } 94 95 if rf, ok := ret.Get(1).(func(context.Context, []string, ...clientv3.OpOption) error); ok { 96 r1 = rf(ctx, keys, opts...) 97 } else { 98 r1 = ret.Error(1) 99 } 100 101 return r0, r1 102 } 103 104 // BatchPut provides a mock function with given fields: ctx, data, opts 105 func (_m *KV) BatchPut(ctx context.Context, data map[string]string, opts ...clientv3.OpOption) (*clientv3.TxnResponse, error) { 106 _va := make([]interface{}, len(opts)) 107 for _i := range opts { 108 _va[_i] = opts[_i] 109 } 110 var _ca []interface{} 111 _ca = append(_ca, ctx, data) 112 _ca = append(_ca, _va...) 113 ret := _m.Called(_ca...) 114 115 var r0 *clientv3.TxnResponse 116 var r1 error 117 if rf, ok := ret.Get(0).(func(context.Context, map[string]string, ...clientv3.OpOption) (*clientv3.TxnResponse, error)); ok { 118 return rf(ctx, data, opts...) 119 } 120 if rf, ok := ret.Get(0).(func(context.Context, map[string]string, ...clientv3.OpOption) *clientv3.TxnResponse); ok { 121 r0 = rf(ctx, data, opts...) 122 } else { 123 if ret.Get(0) != nil { 124 r0 = ret.Get(0).(*clientv3.TxnResponse) 125 } 126 } 127 128 if rf, ok := ret.Get(1).(func(context.Context, map[string]string, ...clientv3.OpOption) error); ok { 129 r1 = rf(ctx, data, opts...) 130 } else { 131 r1 = ret.Error(1) 132 } 133 134 return r0, r1 135 } 136 137 // BatchUpdate provides a mock function with given fields: ctx, data, opts 138 func (_m *KV) BatchUpdate(ctx context.Context, data map[string]string, opts ...clientv3.OpOption) (*clientv3.TxnResponse, error) { 139 _va := make([]interface{}, len(opts)) 140 for _i := range opts { 141 _va[_i] = opts[_i] 142 } 143 var _ca []interface{} 144 _ca = append(_ca, ctx, data) 145 _ca = append(_ca, _va...) 146 ret := _m.Called(_ca...) 147 148 var r0 *clientv3.TxnResponse 149 var r1 error 150 if rf, ok := ret.Get(0).(func(context.Context, map[string]string, ...clientv3.OpOption) (*clientv3.TxnResponse, error)); ok { 151 return rf(ctx, data, opts...) 152 } 153 if rf, ok := ret.Get(0).(func(context.Context, map[string]string, ...clientv3.OpOption) *clientv3.TxnResponse); ok { 154 r0 = rf(ctx, data, opts...) 155 } else { 156 if ret.Get(0) != nil { 157 r0 = ret.Get(0).(*clientv3.TxnResponse) 158 } 159 } 160 161 if rf, ok := ret.Get(1).(func(context.Context, map[string]string, ...clientv3.OpOption) error); ok { 162 r1 = rf(ctx, data, opts...) 163 } else { 164 r1 = ret.Error(1) 165 } 166 167 return r0, r1 168 } 169 170 // BindStatus provides a mock function with given fields: ctx, entityKey, statusKey, statusValue, ttl 171 func (_m *KV) BindStatus(ctx context.Context, entityKey string, statusKey string, statusValue string, ttl int64) error { 172 ret := _m.Called(ctx, entityKey, statusKey, statusValue, ttl) 173 174 var r0 error 175 if rf, ok := ret.Get(0).(func(context.Context, string, string, string, int64) error); ok { 176 r0 = rf(ctx, entityKey, statusKey, statusValue, ttl) 177 } else { 178 r0 = ret.Error(0) 179 } 180 181 return r0 182 } 183 184 // Create provides a mock function with given fields: ctx, key, val, opts 185 func (_m *KV) Create(ctx context.Context, key string, val string, opts ...clientv3.OpOption) (*clientv3.TxnResponse, error) { 186 _va := make([]interface{}, len(opts)) 187 for _i := range opts { 188 _va[_i] = opts[_i] 189 } 190 var _ca []interface{} 191 _ca = append(_ca, ctx, key, val) 192 _ca = append(_ca, _va...) 193 ret := _m.Called(_ca...) 194 195 var r0 *clientv3.TxnResponse 196 var r1 error 197 if rf, ok := ret.Get(0).(func(context.Context, string, string, ...clientv3.OpOption) (*clientv3.TxnResponse, error)); ok { 198 return rf(ctx, key, val, opts...) 199 } 200 if rf, ok := ret.Get(0).(func(context.Context, string, string, ...clientv3.OpOption) *clientv3.TxnResponse); ok { 201 r0 = rf(ctx, key, val, opts...) 202 } else { 203 if ret.Get(0) != nil { 204 r0 = ret.Get(0).(*clientv3.TxnResponse) 205 } 206 } 207 208 if rf, ok := ret.Get(1).(func(context.Context, string, string, ...clientv3.OpOption) error); ok { 209 r1 = rf(ctx, key, val, opts...) 210 } else { 211 r1 = ret.Error(1) 212 } 213 214 return r0, r1 215 } 216 217 // CreateLock provides a mock function with given fields: key, ttl 218 func (_m *KV) CreateLock(key string, ttl time.Duration) (lock.DistributedLock, error) { 219 ret := _m.Called(key, ttl) 220 221 var r0 lock.DistributedLock 222 var r1 error 223 if rf, ok := ret.Get(0).(func(string, time.Duration) (lock.DistributedLock, error)); ok { 224 return rf(key, ttl) 225 } 226 if rf, ok := ret.Get(0).(func(string, time.Duration) lock.DistributedLock); ok { 227 r0 = rf(key, ttl) 228 } else { 229 if ret.Get(0) != nil { 230 r0 = ret.Get(0).(lock.DistributedLock) 231 } 232 } 233 234 if rf, ok := ret.Get(1).(func(string, time.Duration) error); ok { 235 r1 = rf(key, ttl) 236 } else { 237 r1 = ret.Error(1) 238 } 239 240 return r0, r1 241 } 242 243 // Delete provides a mock function with given fields: ctx, key, opts 244 func (_m *KV) Delete(ctx context.Context, key string, opts ...clientv3.OpOption) (*clientv3.DeleteResponse, error) { 245 _va := make([]interface{}, len(opts)) 246 for _i := range opts { 247 _va[_i] = opts[_i] 248 } 249 var _ca []interface{} 250 _ca = append(_ca, ctx, key) 251 _ca = append(_ca, _va...) 252 ret := _m.Called(_ca...) 253 254 var r0 *clientv3.DeleteResponse 255 var r1 error 256 if rf, ok := ret.Get(0).(func(context.Context, string, ...clientv3.OpOption) (*clientv3.DeleteResponse, error)); ok { 257 return rf(ctx, key, opts...) 258 } 259 if rf, ok := ret.Get(0).(func(context.Context, string, ...clientv3.OpOption) *clientv3.DeleteResponse); ok { 260 r0 = rf(ctx, key, opts...) 261 } else { 262 if ret.Get(0) != nil { 263 r0 = ret.Get(0).(*clientv3.DeleteResponse) 264 } 265 } 266 267 if rf, ok := ret.Get(1).(func(context.Context, string, ...clientv3.OpOption) error); ok { 268 r1 = rf(ctx, key, opts...) 269 } else { 270 r1 = ret.Error(1) 271 } 272 273 return r0, r1 274 } 275 276 // Get provides a mock function with given fields: ctx, key, opts 277 func (_m *KV) Get(ctx context.Context, key string, opts ...clientv3.OpOption) (*clientv3.GetResponse, error) { 278 _va := make([]interface{}, len(opts)) 279 for _i := range opts { 280 _va[_i] = opts[_i] 281 } 282 var _ca []interface{} 283 _ca = append(_ca, ctx, key) 284 _ca = append(_ca, _va...) 285 ret := _m.Called(_ca...) 286 287 var r0 *clientv3.GetResponse 288 var r1 error 289 if rf, ok := ret.Get(0).(func(context.Context, string, ...clientv3.OpOption) (*clientv3.GetResponse, error)); ok { 290 return rf(ctx, key, opts...) 291 } 292 if rf, ok := ret.Get(0).(func(context.Context, string, ...clientv3.OpOption) *clientv3.GetResponse); ok { 293 r0 = rf(ctx, key, opts...) 294 } else { 295 if ret.Get(0) != nil { 296 r0 = ret.Get(0).(*clientv3.GetResponse) 297 } 298 } 299 300 if rf, ok := ret.Get(1).(func(context.Context, string, ...clientv3.OpOption) error); ok { 301 r1 = rf(ctx, key, opts...) 302 } else { 303 r1 = ret.Error(1) 304 } 305 306 return r0, r1 307 } 308 309 // GetMulti provides a mock function with given fields: ctx, keys, opts 310 func (_m *KV) GetMulti(ctx context.Context, keys []string, opts ...clientv3.OpOption) ([]*mvccpb.KeyValue, error) { 311 _va := make([]interface{}, len(opts)) 312 for _i := range opts { 313 _va[_i] = opts[_i] 314 } 315 var _ca []interface{} 316 _ca = append(_ca, ctx, keys) 317 _ca = append(_ca, _va...) 318 ret := _m.Called(_ca...) 319 320 var r0 []*mvccpb.KeyValue 321 var r1 error 322 if rf, ok := ret.Get(0).(func(context.Context, []string, ...clientv3.OpOption) ([]*mvccpb.KeyValue, error)); ok { 323 return rf(ctx, keys, opts...) 324 } 325 if rf, ok := ret.Get(0).(func(context.Context, []string, ...clientv3.OpOption) []*mvccpb.KeyValue); ok { 326 r0 = rf(ctx, keys, opts...) 327 } else { 328 if ret.Get(0) != nil { 329 r0 = ret.Get(0).([]*mvccpb.KeyValue) 330 } 331 } 332 333 if rf, ok := ret.Get(1).(func(context.Context, []string, ...clientv3.OpOption) error); ok { 334 r1 = rf(ctx, keys, opts...) 335 } else { 336 r1 = ret.Error(1) 337 } 338 339 return r0, r1 340 } 341 342 // GetOne provides a mock function with given fields: ctx, key, opts 343 func (_m *KV) GetOne(ctx context.Context, key string, opts ...clientv3.OpOption) (*mvccpb.KeyValue, error) { 344 _va := make([]interface{}, len(opts)) 345 for _i := range opts { 346 _va[_i] = opts[_i] 347 } 348 var _ca []interface{} 349 _ca = append(_ca, ctx, key) 350 _ca = append(_ca, _va...) 351 ret := _m.Called(_ca...) 352 353 var r0 *mvccpb.KeyValue 354 var r1 error 355 if rf, ok := ret.Get(0).(func(context.Context, string, ...clientv3.OpOption) (*mvccpb.KeyValue, error)); ok { 356 return rf(ctx, key, opts...) 357 } 358 if rf, ok := ret.Get(0).(func(context.Context, string, ...clientv3.OpOption) *mvccpb.KeyValue); ok { 359 r0 = rf(ctx, key, opts...) 360 } else { 361 if ret.Get(0) != nil { 362 r0 = ret.Get(0).(*mvccpb.KeyValue) 363 } 364 } 365 366 if rf, ok := ret.Get(1).(func(context.Context, string, ...clientv3.OpOption) error); ok { 367 r1 = rf(ctx, key, opts...) 368 } else { 369 r1 = ret.Error(1) 370 } 371 372 return r0, r1 373 } 374 375 // Grant provides a mock function with given fields: ctx, ttl 376 func (_m *KV) Grant(ctx context.Context, ttl int64) (*clientv3.LeaseGrantResponse, error) { 377 ret := _m.Called(ctx, ttl) 378 379 var r0 *clientv3.LeaseGrantResponse 380 var r1 error 381 if rf, ok := ret.Get(0).(func(context.Context, int64) (*clientv3.LeaseGrantResponse, error)); ok { 382 return rf(ctx, ttl) 383 } 384 if rf, ok := ret.Get(0).(func(context.Context, int64) *clientv3.LeaseGrantResponse); ok { 385 r0 = rf(ctx, ttl) 386 } else { 387 if ret.Get(0) != nil { 388 r0 = ret.Get(0).(*clientv3.LeaseGrantResponse) 389 } 390 } 391 392 if rf, ok := ret.Get(1).(func(context.Context, int64) error); ok { 393 r1 = rf(ctx, ttl) 394 } else { 395 r1 = ret.Error(1) 396 } 397 398 return r0, r1 399 } 400 401 // Put provides a mock function with given fields: ctx, key, val, opts 402 func (_m *KV) Put(ctx context.Context, key string, val string, opts ...clientv3.OpOption) (*clientv3.PutResponse, error) { 403 _va := make([]interface{}, len(opts)) 404 for _i := range opts { 405 _va[_i] = opts[_i] 406 } 407 var _ca []interface{} 408 _ca = append(_ca, ctx, key, val) 409 _ca = append(_ca, _va...) 410 ret := _m.Called(_ca...) 411 412 var r0 *clientv3.PutResponse 413 var r1 error 414 if rf, ok := ret.Get(0).(func(context.Context, string, string, ...clientv3.OpOption) (*clientv3.PutResponse, error)); ok { 415 return rf(ctx, key, val, opts...) 416 } 417 if rf, ok := ret.Get(0).(func(context.Context, string, string, ...clientv3.OpOption) *clientv3.PutResponse); ok { 418 r0 = rf(ctx, key, val, opts...) 419 } else { 420 if ret.Get(0) != nil { 421 r0 = ret.Get(0).(*clientv3.PutResponse) 422 } 423 } 424 425 if rf, ok := ret.Get(1).(func(context.Context, string, string, ...clientv3.OpOption) error); ok { 426 r1 = rf(ctx, key, val, opts...) 427 } else { 428 r1 = ret.Error(1) 429 } 430 431 return r0, r1 432 } 433 434 // StartEphemeral provides a mock function with given fields: ctx, path, heartbeat 435 func (_m *KV) StartEphemeral(ctx context.Context, path string, heartbeat time.Duration) (<-chan struct{}, func(), error) { 436 ret := _m.Called(ctx, path, heartbeat) 437 438 var r0 <-chan struct{} 439 var r1 func() 440 var r2 error 441 if rf, ok := ret.Get(0).(func(context.Context, string, time.Duration) (<-chan struct{}, func(), error)); ok { 442 return rf(ctx, path, heartbeat) 443 } 444 if rf, ok := ret.Get(0).(func(context.Context, string, time.Duration) <-chan struct{}); ok { 445 r0 = rf(ctx, path, heartbeat) 446 } else { 447 if ret.Get(0) != nil { 448 r0 = ret.Get(0).(<-chan struct{}) 449 } 450 } 451 452 if rf, ok := ret.Get(1).(func(context.Context, string, time.Duration) func()); ok { 453 r1 = rf(ctx, path, heartbeat) 454 } else { 455 if ret.Get(1) != nil { 456 r1 = ret.Get(1).(func()) 457 } 458 } 459 460 if rf, ok := ret.Get(2).(func(context.Context, string, time.Duration) error); ok { 461 r2 = rf(ctx, path, heartbeat) 462 } else { 463 r2 = ret.Error(2) 464 } 465 466 return r0, r1, r2 467 } 468 469 // Update provides a mock function with given fields: ctx, key, val, opts 470 func (_m *KV) Update(ctx context.Context, key string, val string, opts ...clientv3.OpOption) (*clientv3.TxnResponse, error) { 471 _va := make([]interface{}, len(opts)) 472 for _i := range opts { 473 _va[_i] = opts[_i] 474 } 475 var _ca []interface{} 476 _ca = append(_ca, ctx, key, val) 477 _ca = append(_ca, _va...) 478 ret := _m.Called(_ca...) 479 480 var r0 *clientv3.TxnResponse 481 var r1 error 482 if rf, ok := ret.Get(0).(func(context.Context, string, string, ...clientv3.OpOption) (*clientv3.TxnResponse, error)); ok { 483 return rf(ctx, key, val, opts...) 484 } 485 if rf, ok := ret.Get(0).(func(context.Context, string, string, ...clientv3.OpOption) *clientv3.TxnResponse); ok { 486 r0 = rf(ctx, key, val, opts...) 487 } else { 488 if ret.Get(0) != nil { 489 r0 = ret.Get(0).(*clientv3.TxnResponse) 490 } 491 } 492 493 if rf, ok := ret.Get(1).(func(context.Context, string, string, ...clientv3.OpOption) error); ok { 494 r1 = rf(ctx, key, val, opts...) 495 } else { 496 r1 = ret.Error(1) 497 } 498 499 return r0, r1 500 } 501 502 // Watch provides a mock function with given fields: ctx, key, opts 503 func (_m *KV) Watch(ctx context.Context, key string, opts ...clientv3.OpOption) clientv3.WatchChan { 504 _va := make([]interface{}, len(opts)) 505 for _i := range opts { 506 _va[_i] = opts[_i] 507 } 508 var _ca []interface{} 509 _ca = append(_ca, ctx, key) 510 _ca = append(_ca, _va...) 511 ret := _m.Called(_ca...) 512 513 var r0 clientv3.WatchChan 514 if rf, ok := ret.Get(0).(func(context.Context, string, ...clientv3.OpOption) clientv3.WatchChan); ok { 515 r0 = rf(ctx, key, opts...) 516 } else { 517 if ret.Get(0) != nil { 518 r0 = ret.Get(0).(clientv3.WatchChan) 519 } 520 } 521 522 return r0 523 } 524 525 // NewKV creates a new instance of KV. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. 526 // The first argument is typically a *testing.T value. 527 func NewKV(t interface { 528 mock.TestingT 529 Cleanup(func()) 530 }) *KV { 531 mock := &KV{} 532 mock.Mock.Test(t) 533 534 t.Cleanup(func() { mock.AssertExpectations(t) }) 535 536 return mock 537 }