diff --git a/dev/BUILD.bazel b/dev/BUILD.bazel index 4d90e0a06fc..4abee476036 100644 --- a/dev/BUILD.bazel +++ b/dev/BUILD.bazel @@ -132,6 +132,5 @@ write_source_files( "//cmd/frontend/internal/backend:generate_mocks", "//cmd/enterprise-portal/internal/codyaccessservice:generate_mocks", "//cmd/enterprise-portal/internal/routines/licenseexpiration:generate_mocks", - "//dev/build-tracker/build:generate_mocks", ], ) diff --git a/dev/build-tracker/BUILD.bazel b/dev/build-tracker/BUILD.bazel index e3893dbf56c..027c213780f 100644 --- a/dev/build-tracker/BUILD.bazel +++ b/dev/build-tracker/BUILD.bazel @@ -28,10 +28,7 @@ go_library( "//lib/managedservicesplatform/runtime", "//lib/pointers", "@com_github_buildkite_go_buildkite_v3//buildkite", - "@com_github_go_redsync_redsync_v4//:redsync", - "@com_github_go_redsync_redsync_v4//redis/goredis/v9:goredis", "@com_github_gorilla_mux//:mux", - "@com_github_redis_go_redis_v9//:go-redis", "@com_github_sourcegraph_log//:log", "@com_google_cloud_go_bigquery//:bigquery", "@org_golang_x_exp//maps", @@ -53,7 +50,6 @@ go_test( "main_test.go", "mocks_test.go", "server_test.go", - "util_test.go", ], embed = [":build-tracker_lib"], tags = [TAG_INFRA_DEVINFRA], @@ -66,12 +62,10 @@ go_test( "//lib/pointers", "@com_github_buildkite_go_buildkite_v3//buildkite", "@com_github_gorilla_mux//:mux", - "@com_github_redis_go_redis_v9//:go-redis", "@com_github_sourcegraph_log//logtest", "@com_github_stretchr_testify//assert", "@com_github_stretchr_testify//require", "@com_google_cloud_go_bigquery//:bigquery", - "@org_golang_x_exp//maps", ], ) diff --git a/dev/build-tracker/README.md b/dev/build-tracker/README.md index 1d45ddc9868..0689a27590a 100644 --- a/dev/build-tracker/README.md +++ b/dev/build-tracker/README.md @@ -1,21 +1,27 @@ # BUILD TRACKER -Build Tracker is a server that listens for build events from Buildkite, stores them in Redis and sends notifications about builds if they've failed. +Build Tracker is a server that listens for build events from Buildkite and stores them in memory and sends notifications about builds if they've failed. The server currently listens for two events: - `build.finished` - `job.finished` -For each `job.finished` event that is received, the corresponding `build` is updated with the job that has finished. On receipt of a `build.finished` event, the server will determine if the build has failed by going through all the contained jobs of the build. If one or more jobs have indeed failed, a notification will be sent over slack. As well as this, the server will trigger a Buildkite job to process CI and Bazel data for the build for analytics purposes. +For each `job.finished` event that is received, the corresponding `build` is updated with the job that has finished. On receipt of a `build.finished` event, the server will determine if the build has failed by going through all the contained jobs of the build. If one or more jobs have indeed failed, a notification will be sent over slack. ## Deployment infrastructure -Build Tracker is deployed in MSP. See the auto-generated [Notion doc](https://www.notion.so/sourcegraph/Build-Tracker-infrastructure-operations-bd66bf25d65d41b4875874a6f4d350cc#711a335bc7554738823293334221a18b) for details around accessing the environment and observability systems. +Build Tracker is deployed in the Buildkite kubernetes cluster of the Sourcegraph CI project on GCP. For more information on the deployment see [infrastructure](https://github.com/sourcegraph/infrastructure/tree/main/buildkite/kubernetes) -It is fine to wipe Redis if there are any issues stemming from data inconsistencies, redsync lock problems etc. +## Build -## Notification testing +Execute the `build.sh` script which will build the docker container and push it to correct GCP registry. Once the image has been pushed the pod needs to be restarted so that it can pick up the new image! + +## Test + +To run the tests execute `go test .` + +### Notification testing To test the notifications that get sent over slack you can pass the flag `-RunSlackIntegrationTest` as part of your test invocation, with some required configuration: diff --git a/dev/build-tracker/background.go b/dev/build-tracker/background.go index 993f4757415..fa287cc163d 100644 --- a/dev/build-tracker/background.go +++ b/dev/build-tracker/background.go @@ -12,12 +12,9 @@ import ( func deleteOldBuilds(logger log.Logger, store *build.Store, every, window time.Duration) goroutine.BackgroundRoutine { return goroutine.NewPeriodicGoroutine(context.Background(), goroutine.HandlerFunc(func(ctx context.Context) error { - ctx, cancel := context.WithTimeout(ctx, time.Second*30) - defer cancel() - oldBuilds := make([]int, 0) now := time.Now() - for _, b := range store.FinishedBuilds(ctx) { + for _, b := range store.FinishedBuilds() { finishedAt := *b.FinishedAt delta := now.Sub(finishedAt.Time) if delta >= window { @@ -26,7 +23,7 @@ func deleteOldBuilds(logger log.Logger, store *build.Store, every, window time.D } } logger.Info("deleting old builds", log.Int("oldBuildCount", len(oldBuilds))) - store.DelByBuildNumber(ctx, oldBuilds...) + store.DelByBuildNumber(oldBuilds...) return nil }), goroutine.WithInterval(every), goroutine.WithName("old-build-purger")) } diff --git a/dev/build-tracker/build/BUILD.bazel b/dev/build-tracker/build/BUILD.bazel index f331712c304..06157dcdc89 100644 --- a/dev/build-tracker/build/BUILD.bazel +++ b/dev/build-tracker/build/BUILD.bazel @@ -1,4 +1,3 @@ -load("//dev:go_mockgen.bzl", "go_mockgen") load("//dev:go_defs.bzl", "go_test") load("@io_bazel_rules_go//go:def.bzl", "go_library") @@ -6,7 +5,6 @@ go_library( name = "build", srcs = [ "build.go", - "mocks.go", "steps.go", ], importpath = "github.com/sourcegraph/sourcegraph/dev/build-tracker/build", @@ -17,7 +15,6 @@ go_library( "//lib/errors", "//lib/pointers", "@com_github_buildkite_go_buildkite_v3//buildkite", - "@com_github_redis_go_redis_v9//:go-redis", "@com_github_sourcegraph_log//:log", ], ) @@ -30,20 +27,8 @@ go_test( tags = [TAG_INFRA_DEVINFRA], deps = [ "@com_github_buildkite_go_buildkite_v3//buildkite", - "@com_github_redis_go_redis_v9//:go-redis", "@com_github_sourcegraph_log//logtest", "@com_github_stretchr_testify//assert", "@com_github_stretchr_testify//require", ], ) - -go_mockgen( - name = "generate_mocks", - out = "mocks.go", - manifests = [ - "//:mockgen.yaml", - "//:mockgen.test.yaml", - "//:mockgen.temp.yaml", - ], - deps = [":build"], -) diff --git a/dev/build-tracker/build/build.go b/dev/build-tracker/build/build.go index 3e2105cf2a5..c7c6c5ffc4b 100644 --- a/dev/build-tracker/build/build.go +++ b/dev/build-tracker/build/build.go @@ -1,13 +1,10 @@ package build import ( - "context" - "encoding/json" "fmt" - "strconv" + "sync" "github.com/buildkite/go-buildkite/v3/buildkite" - "github.com/redis/go-redis/v9" "github.com/sourcegraph/log" "github.com/sourcegraph/sourcegraph/dev/build-tracker/notify" @@ -31,6 +28,9 @@ type Build struct { // ConsecutiveFailure indicates whether this build is the nth consecutive failure. ConsecutiveFailure int `json:"consecutiveFailures"` + + // Mutex is used to to control and stop other changes being made to the build. + sync.Mutex } type Step struct { @@ -226,79 +226,45 @@ func (b *Event) GetBuildNumber() int { type Store struct { logger log.Logger - r RedisClient - m1 Locker + builds map[int]*Build + // consecutiveFailures tracks how many consecutive build failed events has been + // received by pipeline and branch + consecutiveFailures map[string]int + + // m locks all writes to BuildStore properties. + m sync.RWMutex } -type Locker interface { - LockContext(context.Context) error - Unlock() (bool, error) -} - -type RedisClient interface { - redis.StringCmdable - redis.GenericCmdable -} - -func NewBuildStore(logger log.Logger, rclient RedisClient, lock Locker) *Store { +func NewBuildStore(logger log.Logger) *Store { return &Store{ logger: logger.Scoped("store"), - r: rclient, - m1: lock, + builds: make(map[int]*Build), + consecutiveFailures: make(map[string]int), + + m: sync.RWMutex{}, } } -func (s *Store) lock(ctx context.Context) (func(), error) { - err := s.m1.LockContext(ctx) - if err != nil { - s.logger.Error("failed to acquire lock", log.Error(err)) - return nil, err - } - return func() { - if _, err := s.m1.Unlock(); err != nil { - s.logger.Error("failed to unlock", log.Error(err)) - } - }, nil -} - -func (s *Store) Add(ctx context.Context, event *Event) { - unlock, err := s.lock(ctx) - if err != nil { - return - } - defer unlock() - - buildb, err := s.r.Get(ctx, "build/"+strconv.Itoa(event.GetBuildNumber())).Bytes() - if err != nil && err != redis.Nil { - s.logger.Error("failed to get build from redis", log.Error(err)) - return - } - - var build *Build - if err == nil { - if err := json.Unmarshal(buildb, &build); err != nil { - s.logger.Error("failed to unmarshal build", log.Error(err)) - return - } - } +func (s *Store) Add(event *Event) { + s.m.Lock() + defer s.m.Unlock() + build, ok := s.builds[event.GetBuildNumber()] // if we don't know about this build, convert it and add it to the store - if err == redis.Nil { + if !ok { build = event.WrappedBuild() + s.builds[event.GetBuildNumber()] = build } - // write out the build to redis at the end, once all mutations are applied - defer func() { - buildb, _ = json.Marshal(build) - s.r.Set(ctx, "build/"+strconv.Itoa(event.GetBuildNumber()), buildb, 0) - }() + // Now that we have a build, lets make sure it isn't modified while we look and possibly update it + build.Lock() + defer build.Unlock() // if the build is finished replace the original build with the replaced one since it // will be more up to date, and tack on some finalized data if event.IsBuildFinished() { build.updateFromEvent(event) - s.logger.Debug("build finished", log.Int("buildNumber", event.GetBuildNumber()), log.Int("totalSteps", len(build.Steps)), log.String("status", build.GetState())) @@ -309,18 +275,12 @@ func (s *Store) Add(ctx context.Context, event *Event) { // We do this because we do not rely on the state of the build to determine if a build is "successful" or not. // We instead depend on the state of the jobs associated with said build. if event.Build.TriggeredFrom != nil { - parentBuildb, err := s.r.Get(ctx, "build/"+strconv.Itoa(*event.Build.TriggeredFrom.BuildNumber)).Bytes() - switch err { - case nil: - var parentBuild *Build - if err := json.Unmarshal(parentBuildb, &parentBuild); err != nil { - s.logger.Error("failed to unmarshal build", log.Error(err)) - return - } + parentBuild, ok := s.builds[*event.Build.TriggeredFrom.BuildNumber] + if ok { + parentBuild.Lock() parentBuild.AppendSteps(build.Steps) - buildb, _ = json.Marshal(parentBuild) - s.r.Set(ctx, "build/"+strconv.Itoa(event.GetBuildNumber()), buildb, 0) - case redis.Nil: + parentBuild.Unlock() + } else { // If the triggered build doesn't exist, we'll just leave log a message s.logger.Warn( "build triggered from non-existent build", @@ -336,19 +296,17 @@ func (s *Store) Add(ctx context.Context, event *Event) { // if we get a pass, we reset the global count of consecutiveFailures failuresKey := fmt.Sprintf("%s/%s", build.Pipeline.GetName(), build.GetBranch()) if build.IsFailed() { - i, _ := s.r.Incr(ctx, failuresKey).Result() - build.ConsecutiveFailure = int(i) + s.consecutiveFailures[failuresKey] += 1 + build.ConsecutiveFailure = s.consecutiveFailures[failuresKey] } else { // We got a pass, reset the global count - if _, err := s.r.Set(ctx, failuresKey, 0, 0).Result(); err != nil { - s.logger.Error("failed to reset consecutive failures count", log.Error(err)) - } + s.consecutiveFailures[failuresKey] = 0 } } // Keep track of the job, if there is one newJob := event.WrappedJob() - err = build.AddJob(newJob) + err := build.AddJob(newJob) if err != nil { s.logger.Warn("job not added", log.Error(err), @@ -375,92 +333,35 @@ func (s *Store) Add(ctx context.Context, event *Event) { } } -func (s *Store) Set(ctx context.Context, build *Build) { - unlock, err := s.lock(ctx) - if err != nil { - return - } - defer unlock() - - buildb, _ := json.Marshal(build) - s.r.Set(ctx, "build/"+strconv.Itoa(*build.Number), buildb, 0) +func (s *Store) Set(build *Build) { + s.m.RLock() + defer s.m.RUnlock() + s.builds[build.GetNumber()] = build } -func (s *Store) GetByBuildNumber(ctx context.Context, num int) *Build { - unlock, err := s.lock(ctx) - if err != nil { - return nil - } - defer unlock() +func (s *Store) GetByBuildNumber(num int) *Build { + s.m.RLock() + defer s.m.RUnlock() - buildb, err := s.r.Get(ctx, "build/"+strconv.Itoa(num)).Bytes() - if err != nil && err != redis.Nil { - s.logger.Error("failed to get build from redis", log.Error(err)) - return nil - } - - var build *Build - if err == nil { - if err := json.Unmarshal(buildb, &build); err != nil { - s.logger.Error("failed to unmarshal build", log.Error(err)) - return nil - } - } - return build + return s.builds[num] } -func (s *Store) DelByBuildNumber(ctx context.Context, buildNumbers ...int) { - unlock, err := s.lock(ctx) - if err != nil { - return - } - defer unlock() +func (s *Store) DelByBuildNumber(buildNumbers ...int) { + s.m.Lock() + defer s.m.Unlock() - nums := make([]string, 0, len(buildNumbers)) for _, num := range buildNumbers { - nums = append(nums, "build/"+strconv.Itoa(num)) + delete(s.builds, num) } - - s.r.Del(ctx, nums...) - s.logger.Info("deleted builds", log.Int("totalBuilds", len(buildNumbers))) } -func (s *Store) FinishedBuilds(ctx context.Context) []*Build { - unlock, err := s.lock(ctx) - if err != nil { - return nil - } - defer unlock() - - buildKeys, err := s.r.Keys(ctx, "build/*").Result() - if err != nil { - s.logger.Error("failed to get build keys", log.Error(err)) - return nil - } - - builds := make([]*Build, 0, len(buildKeys)) - - values, err := s.r.MGet(ctx, buildKeys...).Result() - if err != nil { - s.logger.Error("failed to get build values", log.Error(err)) - return nil - } - - for _, value := range values { - if value == nil { - continue - } - var build *Build - if err := json.Unmarshal([]byte(value.(string)), &build); err != nil { - s.logger.Error("failed to unmarshal build", log.Error(err)) - continue - } - builds = append(builds, build) - } +func (s *Store) FinishedBuilds() []*Build { + s.m.RLock() + defer s.m.RUnlock() finished := make([]*Build, 0) - for _, b := range builds { + for _, b := range s.builds { if b.IsFinished() { s.logger.Debug("build is finished", log.Int("buildNumber", b.GetNumber()), log.String("state", b.GetState())) finished = append(finished, b) diff --git a/dev/build-tracker/build/build_test.go b/dev/build-tracker/build/build_test.go index 78e84a8b103..58c3a4cf30e 100644 --- a/dev/build-tracker/build/build_test.go +++ b/dev/build-tracker/build/build_test.go @@ -1,13 +1,9 @@ package build import ( - "context" - "strings" "testing" - "time" "github.com/buildkite/go-buildkite/v3/buildkite" - "github.com/redis/go-redis/v9" "github.com/sourcegraph/log/logtest" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" @@ -90,61 +86,37 @@ func TestBuildStoreAdd(t *testing.T) { return &Event{Name: EventBuildFinished, Build: buildkite.Build{State: nil, Number: &n}, Pipeline: buildkite.Pipeline{Name: &pipeline}} } - failureCounter := 0 - builds := make(map[string][]byte) - mockredis := NewMockRedisClient() - mockredis.IncrFunc.SetDefaultHook(func(ctx context.Context, key string) *redis.IntCmd { - failureCounter++ - return redis.NewIntResult(int64(failureCounter), nil) - }) - mockredis.SetFunc.SetDefaultHook(func(ctx context.Context, s string, i interface{}, d time.Duration) *redis.StatusCmd { - if strings.HasPrefix(s, pipeline) { - failureCounter = 0 - } else { - builds[s] = i.([]byte) - } - return redis.NewStatusCmd(ctx) - }) - mockredis.GetFunc.SetDefaultHook(func(ctx context.Context, s string) *redis.StringCmd { - if strings.HasPrefix(s, "build/") { - if b, ok := builds[s]; ok { - return redis.NewStringResult(string(b), nil) - } - return redis.NewStringResult("", redis.Nil) - } - return redis.NewStringCmd(ctx) - }) - store := NewBuildStore(logtest.Scoped(t), mockredis, NewMockLocker()) + store := NewBuildStore(logtest.Scoped(t)) t.Run("subsequent failures should increment ConsecutiveFailure", func(t *testing.T) { - store.Add(context.Background(), eventFailed(1)) - build := store.GetByBuildNumber(context.Background(), 1) + store.Add(eventFailed(1)) + build := store.GetByBuildNumber(1) assert.Equal(t, build.ConsecutiveFailure, 1) - store.Add(context.Background(), eventFailed(2)) - build = store.GetByBuildNumber(context.Background(), 2) + store.Add(eventFailed(2)) + build = store.GetByBuildNumber(2) assert.Equal(t, build.ConsecutiveFailure, 2) - store.Add(context.Background(), eventFailed(3)) - build = store.GetByBuildNumber(context.Background(), 3) + store.Add(eventFailed(3)) + build = store.GetByBuildNumber(3) assert.Equal(t, build.ConsecutiveFailure, 3) }) t.Run("a pass should reset ConsecutiveFailure", func(t *testing.T) { - store.Add(context.Background(), eventFailed(4)) - build := store.GetByBuildNumber(context.Background(), 4) + store.Add(eventFailed(4)) + build := store.GetByBuildNumber(4) assert.Equal(t, build.ConsecutiveFailure, 4) - store.Add(context.Background(), eventSucceeded(5)) - build = store.GetByBuildNumber(context.Background(), 5) + store.Add(eventSucceeded(5)) + build = store.GetByBuildNumber(5) assert.Equal(t, build.ConsecutiveFailure, 0) - store.Add(context.Background(), eventFailed(6)) - build = store.GetByBuildNumber(context.Background(), 6) + store.Add(eventFailed(6)) + build = store.GetByBuildNumber(6) assert.Equal(t, build.ConsecutiveFailure, 1) - store.Add(context.Background(), eventSucceeded(7)) - build = store.GetByBuildNumber(context.Background(), 7) + store.Add(eventSucceeded(7)) + build = store.GetByBuildNumber(7) assert.Equal(t, build.ConsecutiveFailure, 0) }) } @@ -159,33 +131,17 @@ func TestBuildFailedJobs(t *testing.T) { Name: EventJobFinished, Build: buildkite.Build{State: &buildState, Number: &buildNumber}, Pipeline: buildkite.Pipeline{Name: &pipeline}, - Job: buildkite.Job{Name: &name, ExitStatus: &exitCode, State: &jobState}, - } + Job: buildkite.Job{Name: &name, ExitStatus: &exitCode, State: &jobState}} } - builds := make(map[string][]byte) - mockredis := NewMockRedisClient() - mockredis.SetFunc.SetDefaultHook(func(ctx context.Context, s string, i interface{}, d time.Duration) *redis.StatusCmd { - builds[s] = i.([]byte) - return redis.NewStatusCmd(ctx) - }) - mockredis.GetFunc.SetDefaultHook(func(ctx context.Context, s string) *redis.StringCmd { - if strings.HasPrefix(s, "build/") { - if b, ok := builds[s]; ok { - return redis.NewStringResult(string(b), nil) - } - return redis.NewStringResult("", redis.Nil) - } - return redis.NewStringCmd(ctx) - }) - store := NewBuildStore(logtest.Scoped(t), mockredis, NewMockLocker()) + store := NewBuildStore(logtest.Scoped(t)) t.Run("failed jobs should contain different jobs", func(t *testing.T) { - store.Add(context.Background(), eventFailed("Test 1", 1)) - store.Add(context.Background(), eventFailed("Test 2", 1)) - store.Add(context.Background(), eventFailed("Test 3", 1)) + store.Add(eventFailed("Test 1", 1)) + store.Add(eventFailed("Test 2", 1)) + store.Add(eventFailed("Test 3", 1)) - build := store.GetByBuildNumber(context.Background(), 1) + build := store.GetByBuildNumber(1) unique := make(map[string]int) for _, s := range FindFailedSteps(build.Steps) { diff --git a/dev/build-tracker/build/mocks.go b/dev/build-tracker/build/mocks.go deleted file mode 100644 index 6fd7ab98485..00000000000 --- a/dev/build-tracker/build/mocks.go +++ /dev/null @@ -1,7606 +0,0 @@ -// Code generated by go-mockgen 1.3.7; DO NOT EDIT. -// -// This file was generated by running `sg generate` (or `go-mockgen`) at the root of -// this repository. To add additional mocks to this or another package, add a new entry -// to the mockgen.yaml file in the root of this repository. - -package build - -import ( - "context" - "sync" - "time" - - v9 "github.com/redis/go-redis/v9" -) - -// MockLocker is a mock implementation of the Locker interface (from the -// package github.com/sourcegraph/sourcegraph/dev/build-tracker/build) used -// for unit testing. -type MockLocker struct { - // LockContextFunc is an instance of a mock function object controlling - // the behavior of the method LockContext. - LockContextFunc *LockerLockContextFunc - // UnlockFunc is an instance of a mock function object controlling the - // behavior of the method Unlock. - UnlockFunc *LockerUnlockFunc -} - -// NewMockLocker creates a new mock of the Locker interface. All methods -// return zero values for all results, unless overwritten. -func NewMockLocker() *MockLocker { - return &MockLocker{ - LockContextFunc: &LockerLockContextFunc{ - defaultHook: func(context.Context) (r0 error) { - return - }, - }, - UnlockFunc: &LockerUnlockFunc{ - defaultHook: func() (r0 bool, r1 error) { - return - }, - }, - } -} - -// NewStrictMockLocker creates a new mock of the Locker interface. All -// methods panic on invocation, unless overwritten. -func NewStrictMockLocker() *MockLocker { - return &MockLocker{ - LockContextFunc: &LockerLockContextFunc{ - defaultHook: func(context.Context) error { - panic("unexpected invocation of MockLocker.LockContext") - }, - }, - UnlockFunc: &LockerUnlockFunc{ - defaultHook: func() (bool, error) { - panic("unexpected invocation of MockLocker.Unlock") - }, - }, - } -} - -// NewMockLockerFrom creates a new mock of the MockLocker interface. All -// methods delegate to the given implementation, unless overwritten. -func NewMockLockerFrom(i Locker) *MockLocker { - return &MockLocker{ - LockContextFunc: &LockerLockContextFunc{ - defaultHook: i.LockContext, - }, - UnlockFunc: &LockerUnlockFunc{ - defaultHook: i.Unlock, - }, - } -} - -// LockerLockContextFunc describes the behavior when the LockContext method -// of the parent MockLocker instance is invoked. -type LockerLockContextFunc struct { - defaultHook func(context.Context) error - hooks []func(context.Context) error - history []LockerLockContextFuncCall - mutex sync.Mutex -} - -// LockContext delegates to the next hook function in the queue and stores -// the parameter and result values of this invocation. -func (m *MockLocker) LockContext(v0 context.Context) error { - r0 := m.LockContextFunc.nextHook()(v0) - m.LockContextFunc.appendCall(LockerLockContextFuncCall{v0, r0}) - return r0 -} - -// SetDefaultHook sets function that is called when the LockContext method -// of the parent MockLocker instance is invoked and the hook queue is empty. -func (f *LockerLockContextFunc) SetDefaultHook(hook func(context.Context) error) { - f.defaultHook = hook -} - -// PushHook adds a function to the end of hook queue. Each invocation of the -// LockContext method of the parent MockLocker instance invokes the hook at -// the front of the queue and discards it. After the queue is empty, the -// default hook function is invoked for any future action. -func (f *LockerLockContextFunc) PushHook(hook func(context.Context) error) { - f.mutex.Lock() - f.hooks = append(f.hooks, hook) - f.mutex.Unlock() -} - -// SetDefaultReturn calls SetDefaultHook with a function that returns the -// given values. -func (f *LockerLockContextFunc) SetDefaultReturn(r0 error) { - f.SetDefaultHook(func(context.Context) error { - return r0 - }) -} - -// PushReturn calls PushHook with a function that returns the given values. -func (f *LockerLockContextFunc) PushReturn(r0 error) { - f.PushHook(func(context.Context) error { - return r0 - }) -} - -func (f *LockerLockContextFunc) nextHook() func(context.Context) error { - f.mutex.Lock() - defer f.mutex.Unlock() - - if len(f.hooks) == 0 { - return f.defaultHook - } - - hook := f.hooks[0] - f.hooks = f.hooks[1:] - return hook -} - -func (f *LockerLockContextFunc) appendCall(r0 LockerLockContextFuncCall) { - f.mutex.Lock() - f.history = append(f.history, r0) - f.mutex.Unlock() -} - -// History returns a sequence of LockerLockContextFuncCall objects -// describing the invocations of this function. -func (f *LockerLockContextFunc) History() []LockerLockContextFuncCall { - f.mutex.Lock() - history := make([]LockerLockContextFuncCall, len(f.history)) - copy(history, f.history) - f.mutex.Unlock() - - return history -} - -// LockerLockContextFuncCall is an object that describes an invocation of -// method LockContext on an instance of MockLocker. -type LockerLockContextFuncCall struct { - // Arg0 is the value of the 1st argument passed to this method - // invocation. - Arg0 context.Context - // Result0 is the value of the 1st result returned from this method - // invocation. - Result0 error -} - -// Args returns an interface slice containing the arguments of this -// invocation. -func (c LockerLockContextFuncCall) Args() []interface{} { - return []interface{}{c.Arg0} -} - -// Results returns an interface slice containing the results of this -// invocation. -func (c LockerLockContextFuncCall) Results() []interface{} { - return []interface{}{c.Result0} -} - -// LockerUnlockFunc describes the behavior when the Unlock method of the -// parent MockLocker instance is invoked. -type LockerUnlockFunc struct { - defaultHook func() (bool, error) - hooks []func() (bool, error) - history []LockerUnlockFuncCall - mutex sync.Mutex -} - -// Unlock delegates to the next hook function in the queue and stores the -// parameter and result values of this invocation. -func (m *MockLocker) Unlock() (bool, error) { - r0, r1 := m.UnlockFunc.nextHook()() - m.UnlockFunc.appendCall(LockerUnlockFuncCall{r0, r1}) - return r0, r1 -} - -// SetDefaultHook sets function that is called when the Unlock method of the -// parent MockLocker instance is invoked and the hook queue is empty. -func (f *LockerUnlockFunc) SetDefaultHook(hook func() (bool, error)) { - f.defaultHook = hook -} - -// PushHook adds a function to the end of hook queue. Each invocation of the -// Unlock method of the parent MockLocker instance invokes the hook at the -// front of the queue and discards it. After the queue is empty, the default -// hook function is invoked for any future action. -func (f *LockerUnlockFunc) PushHook(hook func() (bool, error)) { - f.mutex.Lock() - f.hooks = append(f.hooks, hook) - f.mutex.Unlock() -} - -// SetDefaultReturn calls SetDefaultHook with a function that returns the -// given values. -func (f *LockerUnlockFunc) SetDefaultReturn(r0 bool, r1 error) { - f.SetDefaultHook(func() (bool, error) { - return r0, r1 - }) -} - -// PushReturn calls PushHook with a function that returns the given values. -func (f *LockerUnlockFunc) PushReturn(r0 bool, r1 error) { - f.PushHook(func() (bool, error) { - return r0, r1 - }) -} - -func (f *LockerUnlockFunc) nextHook() func() (bool, error) { - f.mutex.Lock() - defer f.mutex.Unlock() - - if len(f.hooks) == 0 { - return f.defaultHook - } - - hook := f.hooks[0] - f.hooks = f.hooks[1:] - return hook -} - -func (f *LockerUnlockFunc) appendCall(r0 LockerUnlockFuncCall) { - f.mutex.Lock() - f.history = append(f.history, r0) - f.mutex.Unlock() -} - -// History returns a sequence of LockerUnlockFuncCall objects describing the -// invocations of this function. -func (f *LockerUnlockFunc) History() []LockerUnlockFuncCall { - f.mutex.Lock() - history := make([]LockerUnlockFuncCall, len(f.history)) - copy(history, f.history) - f.mutex.Unlock() - - return history -} - -// LockerUnlockFuncCall is an object that describes an invocation of method -// Unlock on an instance of MockLocker. -type LockerUnlockFuncCall struct { - // Result0 is the value of the 1st result returned from this method - // invocation. - Result0 bool - // Result1 is the value of the 2nd result returned from this method - // invocation. - Result1 error -} - -// Args returns an interface slice containing the arguments of this -// invocation. -func (c LockerUnlockFuncCall) Args() []interface{} { - return []interface{}{} -} - -// Results returns an interface slice containing the results of this -// invocation. -func (c LockerUnlockFuncCall) Results() []interface{} { - return []interface{}{c.Result0, c.Result1} -} - -// MockRedisClient is a mock implementation of the RedisClient interface -// (from the package -// github.com/sourcegraph/sourcegraph/dev/build-tracker/build) used for unit -// testing. -type MockRedisClient struct { - // AppendFunc is an instance of a mock function object controlling the - // behavior of the method Append. - AppendFunc *RedisClientAppendFunc - // CopyFunc is an instance of a mock function object controlling the - // behavior of the method Copy. - CopyFunc *RedisClientCopyFunc - // DecrFunc is an instance of a mock function object controlling the - // behavior of the method Decr. - DecrFunc *RedisClientDecrFunc - // DecrByFunc is an instance of a mock function object controlling the - // behavior of the method DecrBy. - DecrByFunc *RedisClientDecrByFunc - // DelFunc is an instance of a mock function object controlling the - // behavior of the method Del. - DelFunc *RedisClientDelFunc - // DumpFunc is an instance of a mock function object controlling the - // behavior of the method Dump. - DumpFunc *RedisClientDumpFunc - // ExistsFunc is an instance of a mock function object controlling the - // behavior of the method Exists. - ExistsFunc *RedisClientExistsFunc - // ExpireFunc is an instance of a mock function object controlling the - // behavior of the method Expire. - ExpireFunc *RedisClientExpireFunc - // ExpireAtFunc is an instance of a mock function object controlling the - // behavior of the method ExpireAt. - ExpireAtFunc *RedisClientExpireAtFunc - // ExpireGTFunc is an instance of a mock function object controlling the - // behavior of the method ExpireGT. - ExpireGTFunc *RedisClientExpireGTFunc - // ExpireLTFunc is an instance of a mock function object controlling the - // behavior of the method ExpireLT. - ExpireLTFunc *RedisClientExpireLTFunc - // ExpireNXFunc is an instance of a mock function object controlling the - // behavior of the method ExpireNX. - ExpireNXFunc *RedisClientExpireNXFunc - // ExpireTimeFunc is an instance of a mock function object controlling - // the behavior of the method ExpireTime. - ExpireTimeFunc *RedisClientExpireTimeFunc - // ExpireXXFunc is an instance of a mock function object controlling the - // behavior of the method ExpireXX. - ExpireXXFunc *RedisClientExpireXXFunc - // GetFunc is an instance of a mock function object controlling the - // behavior of the method Get. - GetFunc *RedisClientGetFunc - // GetDelFunc is an instance of a mock function object controlling the - // behavior of the method GetDel. - GetDelFunc *RedisClientGetDelFunc - // GetExFunc is an instance of a mock function object controlling the - // behavior of the method GetEx. - GetExFunc *RedisClientGetExFunc - // GetRangeFunc is an instance of a mock function object controlling the - // behavior of the method GetRange. - GetRangeFunc *RedisClientGetRangeFunc - // GetSetFunc is an instance of a mock function object controlling the - // behavior of the method GetSet. - GetSetFunc *RedisClientGetSetFunc - // IncrFunc is an instance of a mock function object controlling the - // behavior of the method Incr. - IncrFunc *RedisClientIncrFunc - // IncrByFunc is an instance of a mock function object controlling the - // behavior of the method IncrBy. - IncrByFunc *RedisClientIncrByFunc - // IncrByFloatFunc is an instance of a mock function object controlling - // the behavior of the method IncrByFloat. - IncrByFloatFunc *RedisClientIncrByFloatFunc - // KeysFunc is an instance of a mock function object controlling the - // behavior of the method Keys. - KeysFunc *RedisClientKeysFunc - // LCSFunc is an instance of a mock function object controlling the - // behavior of the method LCS. - LCSFunc *RedisClientLCSFunc - // MGetFunc is an instance of a mock function object controlling the - // behavior of the method MGet. - MGetFunc *RedisClientMGetFunc - // MSetFunc is an instance of a mock function object controlling the - // behavior of the method MSet. - MSetFunc *RedisClientMSetFunc - // MSetNXFunc is an instance of a mock function object controlling the - // behavior of the method MSetNX. - MSetNXFunc *RedisClientMSetNXFunc - // MigrateFunc is an instance of a mock function object controlling the - // behavior of the method Migrate. - MigrateFunc *RedisClientMigrateFunc - // MoveFunc is an instance of a mock function object controlling the - // behavior of the method Move. - MoveFunc *RedisClientMoveFunc - // ObjectEncodingFunc is an instance of a mock function object - // controlling the behavior of the method ObjectEncoding. - ObjectEncodingFunc *RedisClientObjectEncodingFunc - // ObjectFreqFunc is an instance of a mock function object controlling - // the behavior of the method ObjectFreq. - ObjectFreqFunc *RedisClientObjectFreqFunc - // ObjectIdleTimeFunc is an instance of a mock function object - // controlling the behavior of the method ObjectIdleTime. - ObjectIdleTimeFunc *RedisClientObjectIdleTimeFunc - // ObjectRefCountFunc is an instance of a mock function object - // controlling the behavior of the method ObjectRefCount. - ObjectRefCountFunc *RedisClientObjectRefCountFunc - // PExpireFunc is an instance of a mock function object controlling the - // behavior of the method PExpire. - PExpireFunc *RedisClientPExpireFunc - // PExpireAtFunc is an instance of a mock function object controlling - // the behavior of the method PExpireAt. - PExpireAtFunc *RedisClientPExpireAtFunc - // PExpireTimeFunc is an instance of a mock function object controlling - // the behavior of the method PExpireTime. - PExpireTimeFunc *RedisClientPExpireTimeFunc - // PTTLFunc is an instance of a mock function object controlling the - // behavior of the method PTTL. - PTTLFunc *RedisClientPTTLFunc - // PersistFunc is an instance of a mock function object controlling the - // behavior of the method Persist. - PersistFunc *RedisClientPersistFunc - // RandomKeyFunc is an instance of a mock function object controlling - // the behavior of the method RandomKey. - RandomKeyFunc *RedisClientRandomKeyFunc - // RenameFunc is an instance of a mock function object controlling the - // behavior of the method Rename. - RenameFunc *RedisClientRenameFunc - // RenameNXFunc is an instance of a mock function object controlling the - // behavior of the method RenameNX. - RenameNXFunc *RedisClientRenameNXFunc - // RestoreFunc is an instance of a mock function object controlling the - // behavior of the method Restore. - RestoreFunc *RedisClientRestoreFunc - // RestoreReplaceFunc is an instance of a mock function object - // controlling the behavior of the method RestoreReplace. - RestoreReplaceFunc *RedisClientRestoreReplaceFunc - // ScanFunc is an instance of a mock function object controlling the - // behavior of the method Scan. - ScanFunc *RedisClientScanFunc - // ScanTypeFunc is an instance of a mock function object controlling the - // behavior of the method ScanType. - ScanTypeFunc *RedisClientScanTypeFunc - // SetFunc is an instance of a mock function object controlling the - // behavior of the method Set. - SetFunc *RedisClientSetFunc - // SetArgsFunc is an instance of a mock function object controlling the - // behavior of the method SetArgs. - SetArgsFunc *RedisClientSetArgsFunc - // SetExFunc is an instance of a mock function object controlling the - // behavior of the method SetEx. - SetExFunc *RedisClientSetExFunc - // SetNXFunc is an instance of a mock function object controlling the - // behavior of the method SetNX. - SetNXFunc *RedisClientSetNXFunc - // SetRangeFunc is an instance of a mock function object controlling the - // behavior of the method SetRange. - SetRangeFunc *RedisClientSetRangeFunc - // SetXXFunc is an instance of a mock function object controlling the - // behavior of the method SetXX. - SetXXFunc *RedisClientSetXXFunc - // SortFunc is an instance of a mock function object controlling the - // behavior of the method Sort. - SortFunc *RedisClientSortFunc - // SortInterfacesFunc is an instance of a mock function object - // controlling the behavior of the method SortInterfaces. - SortInterfacesFunc *RedisClientSortInterfacesFunc - // SortROFunc is an instance of a mock function object controlling the - // behavior of the method SortRO. - SortROFunc *RedisClientSortROFunc - // SortStoreFunc is an instance of a mock function object controlling - // the behavior of the method SortStore. - SortStoreFunc *RedisClientSortStoreFunc - // StrLenFunc is an instance of a mock function object controlling the - // behavior of the method StrLen. - StrLenFunc *RedisClientStrLenFunc - // TTLFunc is an instance of a mock function object controlling the - // behavior of the method TTL. - TTLFunc *RedisClientTTLFunc - // TouchFunc is an instance of a mock function object controlling the - // behavior of the method Touch. - TouchFunc *RedisClientTouchFunc - // TypeFunc is an instance of a mock function object controlling the - // behavior of the method Type. - TypeFunc *RedisClientTypeFunc -} - -// NewMockRedisClient creates a new mock of the RedisClient interface. All -// methods return zero values for all results, unless overwritten. -func NewMockRedisClient() *MockRedisClient { - return &MockRedisClient{ - AppendFunc: &RedisClientAppendFunc{ - defaultHook: func(context.Context, string, string) (r0 *v9.IntCmd) { - return - }, - }, - CopyFunc: &RedisClientCopyFunc{ - defaultHook: func(context.Context, string, string, int, bool) (r0 *v9.IntCmd) { - return - }, - }, - DecrFunc: &RedisClientDecrFunc{ - defaultHook: func(context.Context, string) (r0 *v9.IntCmd) { - return - }, - }, - DecrByFunc: &RedisClientDecrByFunc{ - defaultHook: func(context.Context, string, int64) (r0 *v9.IntCmd) { - return - }, - }, - DelFunc: &RedisClientDelFunc{ - defaultHook: func(context.Context, ...string) (r0 *v9.IntCmd) { - return - }, - }, - DumpFunc: &RedisClientDumpFunc{ - defaultHook: func(context.Context, string) (r0 *v9.StringCmd) { - return - }, - }, - ExistsFunc: &RedisClientExistsFunc{ - defaultHook: func(context.Context, ...string) (r0 *v9.IntCmd) { - return - }, - }, - ExpireFunc: &RedisClientExpireFunc{ - defaultHook: func(context.Context, string, time.Duration) (r0 *v9.BoolCmd) { - return - }, - }, - ExpireAtFunc: &RedisClientExpireAtFunc{ - defaultHook: func(context.Context, string, time.Time) (r0 *v9.BoolCmd) { - return - }, - }, - ExpireGTFunc: &RedisClientExpireGTFunc{ - defaultHook: func(context.Context, string, time.Duration) (r0 *v9.BoolCmd) { - return - }, - }, - ExpireLTFunc: &RedisClientExpireLTFunc{ - defaultHook: func(context.Context, string, time.Duration) (r0 *v9.BoolCmd) { - return - }, - }, - ExpireNXFunc: &RedisClientExpireNXFunc{ - defaultHook: func(context.Context, string, time.Duration) (r0 *v9.BoolCmd) { - return - }, - }, - ExpireTimeFunc: &RedisClientExpireTimeFunc{ - defaultHook: func(context.Context, string) (r0 *v9.DurationCmd) { - return - }, - }, - ExpireXXFunc: &RedisClientExpireXXFunc{ - defaultHook: func(context.Context, string, time.Duration) (r0 *v9.BoolCmd) { - return - }, - }, - GetFunc: &RedisClientGetFunc{ - defaultHook: func(context.Context, string) (r0 *v9.StringCmd) { - return - }, - }, - GetDelFunc: &RedisClientGetDelFunc{ - defaultHook: func(context.Context, string) (r0 *v9.StringCmd) { - return - }, - }, - GetExFunc: &RedisClientGetExFunc{ - defaultHook: func(context.Context, string, time.Duration) (r0 *v9.StringCmd) { - return - }, - }, - GetRangeFunc: &RedisClientGetRangeFunc{ - defaultHook: func(context.Context, string, int64, int64) (r0 *v9.StringCmd) { - return - }, - }, - GetSetFunc: &RedisClientGetSetFunc{ - defaultHook: func(context.Context, string, interface{}) (r0 *v9.StringCmd) { - return - }, - }, - IncrFunc: &RedisClientIncrFunc{ - defaultHook: func(context.Context, string) (r0 *v9.IntCmd) { - return - }, - }, - IncrByFunc: &RedisClientIncrByFunc{ - defaultHook: func(context.Context, string, int64) (r0 *v9.IntCmd) { - return - }, - }, - IncrByFloatFunc: &RedisClientIncrByFloatFunc{ - defaultHook: func(context.Context, string, float64) (r0 *v9.FloatCmd) { - return - }, - }, - KeysFunc: &RedisClientKeysFunc{ - defaultHook: func(context.Context, string) (r0 *v9.StringSliceCmd) { - return - }, - }, - LCSFunc: &RedisClientLCSFunc{ - defaultHook: func(context.Context, *v9.LCSQuery) (r0 *v9.LCSCmd) { - return - }, - }, - MGetFunc: &RedisClientMGetFunc{ - defaultHook: func(context.Context, ...string) (r0 *v9.SliceCmd) { - return - }, - }, - MSetFunc: &RedisClientMSetFunc{ - defaultHook: func(context.Context, ...interface{}) (r0 *v9.StatusCmd) { - return - }, - }, - MSetNXFunc: &RedisClientMSetNXFunc{ - defaultHook: func(context.Context, ...interface{}) (r0 *v9.BoolCmd) { - return - }, - }, - MigrateFunc: &RedisClientMigrateFunc{ - defaultHook: func(context.Context, string, string, string, int, time.Duration) (r0 *v9.StatusCmd) { - return - }, - }, - MoveFunc: &RedisClientMoveFunc{ - defaultHook: func(context.Context, string, int) (r0 *v9.BoolCmd) { - return - }, - }, - ObjectEncodingFunc: &RedisClientObjectEncodingFunc{ - defaultHook: func(context.Context, string) (r0 *v9.StringCmd) { - return - }, - }, - ObjectFreqFunc: &RedisClientObjectFreqFunc{ - defaultHook: func(context.Context, string) (r0 *v9.IntCmd) { - return - }, - }, - ObjectIdleTimeFunc: &RedisClientObjectIdleTimeFunc{ - defaultHook: func(context.Context, string) (r0 *v9.DurationCmd) { - return - }, - }, - ObjectRefCountFunc: &RedisClientObjectRefCountFunc{ - defaultHook: func(context.Context, string) (r0 *v9.IntCmd) { - return - }, - }, - PExpireFunc: &RedisClientPExpireFunc{ - defaultHook: func(context.Context, string, time.Duration) (r0 *v9.BoolCmd) { - return - }, - }, - PExpireAtFunc: &RedisClientPExpireAtFunc{ - defaultHook: func(context.Context, string, time.Time) (r0 *v9.BoolCmd) { - return - }, - }, - PExpireTimeFunc: &RedisClientPExpireTimeFunc{ - defaultHook: func(context.Context, string) (r0 *v9.DurationCmd) { - return - }, - }, - PTTLFunc: &RedisClientPTTLFunc{ - defaultHook: func(context.Context, string) (r0 *v9.DurationCmd) { - return - }, - }, - PersistFunc: &RedisClientPersistFunc{ - defaultHook: func(context.Context, string) (r0 *v9.BoolCmd) { - return - }, - }, - RandomKeyFunc: &RedisClientRandomKeyFunc{ - defaultHook: func(context.Context) (r0 *v9.StringCmd) { - return - }, - }, - RenameFunc: &RedisClientRenameFunc{ - defaultHook: func(context.Context, string, string) (r0 *v9.StatusCmd) { - return - }, - }, - RenameNXFunc: &RedisClientRenameNXFunc{ - defaultHook: func(context.Context, string, string) (r0 *v9.BoolCmd) { - return - }, - }, - RestoreFunc: &RedisClientRestoreFunc{ - defaultHook: func(context.Context, string, time.Duration, string) (r0 *v9.StatusCmd) { - return - }, - }, - RestoreReplaceFunc: &RedisClientRestoreReplaceFunc{ - defaultHook: func(context.Context, string, time.Duration, string) (r0 *v9.StatusCmd) { - return - }, - }, - ScanFunc: &RedisClientScanFunc{ - defaultHook: func(context.Context, uint64, string, int64) (r0 *v9.ScanCmd) { - return - }, - }, - ScanTypeFunc: &RedisClientScanTypeFunc{ - defaultHook: func(context.Context, uint64, string, int64, string) (r0 *v9.ScanCmd) { - return - }, - }, - SetFunc: &RedisClientSetFunc{ - defaultHook: func(context.Context, string, interface{}, time.Duration) (r0 *v9.StatusCmd) { - return - }, - }, - SetArgsFunc: &RedisClientSetArgsFunc{ - defaultHook: func(context.Context, string, interface{}, v9.SetArgs) (r0 *v9.StatusCmd) { - return - }, - }, - SetExFunc: &RedisClientSetExFunc{ - defaultHook: func(context.Context, string, interface{}, time.Duration) (r0 *v9.StatusCmd) { - return - }, - }, - SetNXFunc: &RedisClientSetNXFunc{ - defaultHook: func(context.Context, string, interface{}, time.Duration) (r0 *v9.BoolCmd) { - return - }, - }, - SetRangeFunc: &RedisClientSetRangeFunc{ - defaultHook: func(context.Context, string, int64, string) (r0 *v9.IntCmd) { - return - }, - }, - SetXXFunc: &RedisClientSetXXFunc{ - defaultHook: func(context.Context, string, interface{}, time.Duration) (r0 *v9.BoolCmd) { - return - }, - }, - SortFunc: &RedisClientSortFunc{ - defaultHook: func(context.Context, string, *v9.Sort) (r0 *v9.StringSliceCmd) { - return - }, - }, - SortInterfacesFunc: &RedisClientSortInterfacesFunc{ - defaultHook: func(context.Context, string, *v9.Sort) (r0 *v9.SliceCmd) { - return - }, - }, - SortROFunc: &RedisClientSortROFunc{ - defaultHook: func(context.Context, string, *v9.Sort) (r0 *v9.StringSliceCmd) { - return - }, - }, - SortStoreFunc: &RedisClientSortStoreFunc{ - defaultHook: func(context.Context, string, string, *v9.Sort) (r0 *v9.IntCmd) { - return - }, - }, - StrLenFunc: &RedisClientStrLenFunc{ - defaultHook: func(context.Context, string) (r0 *v9.IntCmd) { - return - }, - }, - TTLFunc: &RedisClientTTLFunc{ - defaultHook: func(context.Context, string) (r0 *v9.DurationCmd) { - return - }, - }, - TouchFunc: &RedisClientTouchFunc{ - defaultHook: func(context.Context, ...string) (r0 *v9.IntCmd) { - return - }, - }, - TypeFunc: &RedisClientTypeFunc{ - defaultHook: func(context.Context, string) (r0 *v9.StatusCmd) { - return - }, - }, - } -} - -// NewStrictMockRedisClient creates a new mock of the RedisClient interface. -// All methods panic on invocation, unless overwritten. -func NewStrictMockRedisClient() *MockRedisClient { - return &MockRedisClient{ - AppendFunc: &RedisClientAppendFunc{ - defaultHook: func(context.Context, string, string) *v9.IntCmd { - panic("unexpected invocation of MockRedisClient.Append") - }, - }, - CopyFunc: &RedisClientCopyFunc{ - defaultHook: func(context.Context, string, string, int, bool) *v9.IntCmd { - panic("unexpected invocation of MockRedisClient.Copy") - }, - }, - DecrFunc: &RedisClientDecrFunc{ - defaultHook: func(context.Context, string) *v9.IntCmd { - panic("unexpected invocation of MockRedisClient.Decr") - }, - }, - DecrByFunc: &RedisClientDecrByFunc{ - defaultHook: func(context.Context, string, int64) *v9.IntCmd { - panic("unexpected invocation of MockRedisClient.DecrBy") - }, - }, - DelFunc: &RedisClientDelFunc{ - defaultHook: func(context.Context, ...string) *v9.IntCmd { - panic("unexpected invocation of MockRedisClient.Del") - }, - }, - DumpFunc: &RedisClientDumpFunc{ - defaultHook: func(context.Context, string) *v9.StringCmd { - panic("unexpected invocation of MockRedisClient.Dump") - }, - }, - ExistsFunc: &RedisClientExistsFunc{ - defaultHook: func(context.Context, ...string) *v9.IntCmd { - panic("unexpected invocation of MockRedisClient.Exists") - }, - }, - ExpireFunc: &RedisClientExpireFunc{ - defaultHook: func(context.Context, string, time.Duration) *v9.BoolCmd { - panic("unexpected invocation of MockRedisClient.Expire") - }, - }, - ExpireAtFunc: &RedisClientExpireAtFunc{ - defaultHook: func(context.Context, string, time.Time) *v9.BoolCmd { - panic("unexpected invocation of MockRedisClient.ExpireAt") - }, - }, - ExpireGTFunc: &RedisClientExpireGTFunc{ - defaultHook: func(context.Context, string, time.Duration) *v9.BoolCmd { - panic("unexpected invocation of MockRedisClient.ExpireGT") - }, - }, - ExpireLTFunc: &RedisClientExpireLTFunc{ - defaultHook: func(context.Context, string, time.Duration) *v9.BoolCmd { - panic("unexpected invocation of MockRedisClient.ExpireLT") - }, - }, - ExpireNXFunc: &RedisClientExpireNXFunc{ - defaultHook: func(context.Context, string, time.Duration) *v9.BoolCmd { - panic("unexpected invocation of MockRedisClient.ExpireNX") - }, - }, - ExpireTimeFunc: &RedisClientExpireTimeFunc{ - defaultHook: func(context.Context, string) *v9.DurationCmd { - panic("unexpected invocation of MockRedisClient.ExpireTime") - }, - }, - ExpireXXFunc: &RedisClientExpireXXFunc{ - defaultHook: func(context.Context, string, time.Duration) *v9.BoolCmd { - panic("unexpected invocation of MockRedisClient.ExpireXX") - }, - }, - GetFunc: &RedisClientGetFunc{ - defaultHook: func(context.Context, string) *v9.StringCmd { - panic("unexpected invocation of MockRedisClient.Get") - }, - }, - GetDelFunc: &RedisClientGetDelFunc{ - defaultHook: func(context.Context, string) *v9.StringCmd { - panic("unexpected invocation of MockRedisClient.GetDel") - }, - }, - GetExFunc: &RedisClientGetExFunc{ - defaultHook: func(context.Context, string, time.Duration) *v9.StringCmd { - panic("unexpected invocation of MockRedisClient.GetEx") - }, - }, - GetRangeFunc: &RedisClientGetRangeFunc{ - defaultHook: func(context.Context, string, int64, int64) *v9.StringCmd { - panic("unexpected invocation of MockRedisClient.GetRange") - }, - }, - GetSetFunc: &RedisClientGetSetFunc{ - defaultHook: func(context.Context, string, interface{}) *v9.StringCmd { - panic("unexpected invocation of MockRedisClient.GetSet") - }, - }, - IncrFunc: &RedisClientIncrFunc{ - defaultHook: func(context.Context, string) *v9.IntCmd { - panic("unexpected invocation of MockRedisClient.Incr") - }, - }, - IncrByFunc: &RedisClientIncrByFunc{ - defaultHook: func(context.Context, string, int64) *v9.IntCmd { - panic("unexpected invocation of MockRedisClient.IncrBy") - }, - }, - IncrByFloatFunc: &RedisClientIncrByFloatFunc{ - defaultHook: func(context.Context, string, float64) *v9.FloatCmd { - panic("unexpected invocation of MockRedisClient.IncrByFloat") - }, - }, - KeysFunc: &RedisClientKeysFunc{ - defaultHook: func(context.Context, string) *v9.StringSliceCmd { - panic("unexpected invocation of MockRedisClient.Keys") - }, - }, - LCSFunc: &RedisClientLCSFunc{ - defaultHook: func(context.Context, *v9.LCSQuery) *v9.LCSCmd { - panic("unexpected invocation of MockRedisClient.LCS") - }, - }, - MGetFunc: &RedisClientMGetFunc{ - defaultHook: func(context.Context, ...string) *v9.SliceCmd { - panic("unexpected invocation of MockRedisClient.MGet") - }, - }, - MSetFunc: &RedisClientMSetFunc{ - defaultHook: func(context.Context, ...interface{}) *v9.StatusCmd { - panic("unexpected invocation of MockRedisClient.MSet") - }, - }, - MSetNXFunc: &RedisClientMSetNXFunc{ - defaultHook: func(context.Context, ...interface{}) *v9.BoolCmd { - panic("unexpected invocation of MockRedisClient.MSetNX") - }, - }, - MigrateFunc: &RedisClientMigrateFunc{ - defaultHook: func(context.Context, string, string, string, int, time.Duration) *v9.StatusCmd { - panic("unexpected invocation of MockRedisClient.Migrate") - }, - }, - MoveFunc: &RedisClientMoveFunc{ - defaultHook: func(context.Context, string, int) *v9.BoolCmd { - panic("unexpected invocation of MockRedisClient.Move") - }, - }, - ObjectEncodingFunc: &RedisClientObjectEncodingFunc{ - defaultHook: func(context.Context, string) *v9.StringCmd { - panic("unexpected invocation of MockRedisClient.ObjectEncoding") - }, - }, - ObjectFreqFunc: &RedisClientObjectFreqFunc{ - defaultHook: func(context.Context, string) *v9.IntCmd { - panic("unexpected invocation of MockRedisClient.ObjectFreq") - }, - }, - ObjectIdleTimeFunc: &RedisClientObjectIdleTimeFunc{ - defaultHook: func(context.Context, string) *v9.DurationCmd { - panic("unexpected invocation of MockRedisClient.ObjectIdleTime") - }, - }, - ObjectRefCountFunc: &RedisClientObjectRefCountFunc{ - defaultHook: func(context.Context, string) *v9.IntCmd { - panic("unexpected invocation of MockRedisClient.ObjectRefCount") - }, - }, - PExpireFunc: &RedisClientPExpireFunc{ - defaultHook: func(context.Context, string, time.Duration) *v9.BoolCmd { - panic("unexpected invocation of MockRedisClient.PExpire") - }, - }, - PExpireAtFunc: &RedisClientPExpireAtFunc{ - defaultHook: func(context.Context, string, time.Time) *v9.BoolCmd { - panic("unexpected invocation of MockRedisClient.PExpireAt") - }, - }, - PExpireTimeFunc: &RedisClientPExpireTimeFunc{ - defaultHook: func(context.Context, string) *v9.DurationCmd { - panic("unexpected invocation of MockRedisClient.PExpireTime") - }, - }, - PTTLFunc: &RedisClientPTTLFunc{ - defaultHook: func(context.Context, string) *v9.DurationCmd { - panic("unexpected invocation of MockRedisClient.PTTL") - }, - }, - PersistFunc: &RedisClientPersistFunc{ - defaultHook: func(context.Context, string) *v9.BoolCmd { - panic("unexpected invocation of MockRedisClient.Persist") - }, - }, - RandomKeyFunc: &RedisClientRandomKeyFunc{ - defaultHook: func(context.Context) *v9.StringCmd { - panic("unexpected invocation of MockRedisClient.RandomKey") - }, - }, - RenameFunc: &RedisClientRenameFunc{ - defaultHook: func(context.Context, string, string) *v9.StatusCmd { - panic("unexpected invocation of MockRedisClient.Rename") - }, - }, - RenameNXFunc: &RedisClientRenameNXFunc{ - defaultHook: func(context.Context, string, string) *v9.BoolCmd { - panic("unexpected invocation of MockRedisClient.RenameNX") - }, - }, - RestoreFunc: &RedisClientRestoreFunc{ - defaultHook: func(context.Context, string, time.Duration, string) *v9.StatusCmd { - panic("unexpected invocation of MockRedisClient.Restore") - }, - }, - RestoreReplaceFunc: &RedisClientRestoreReplaceFunc{ - defaultHook: func(context.Context, string, time.Duration, string) *v9.StatusCmd { - panic("unexpected invocation of MockRedisClient.RestoreReplace") - }, - }, - ScanFunc: &RedisClientScanFunc{ - defaultHook: func(context.Context, uint64, string, int64) *v9.ScanCmd { - panic("unexpected invocation of MockRedisClient.Scan") - }, - }, - ScanTypeFunc: &RedisClientScanTypeFunc{ - defaultHook: func(context.Context, uint64, string, int64, string) *v9.ScanCmd { - panic("unexpected invocation of MockRedisClient.ScanType") - }, - }, - SetFunc: &RedisClientSetFunc{ - defaultHook: func(context.Context, string, interface{}, time.Duration) *v9.StatusCmd { - panic("unexpected invocation of MockRedisClient.Set") - }, - }, - SetArgsFunc: &RedisClientSetArgsFunc{ - defaultHook: func(context.Context, string, interface{}, v9.SetArgs) *v9.StatusCmd { - panic("unexpected invocation of MockRedisClient.SetArgs") - }, - }, - SetExFunc: &RedisClientSetExFunc{ - defaultHook: func(context.Context, string, interface{}, time.Duration) *v9.StatusCmd { - panic("unexpected invocation of MockRedisClient.SetEx") - }, - }, - SetNXFunc: &RedisClientSetNXFunc{ - defaultHook: func(context.Context, string, interface{}, time.Duration) *v9.BoolCmd { - panic("unexpected invocation of MockRedisClient.SetNX") - }, - }, - SetRangeFunc: &RedisClientSetRangeFunc{ - defaultHook: func(context.Context, string, int64, string) *v9.IntCmd { - panic("unexpected invocation of MockRedisClient.SetRange") - }, - }, - SetXXFunc: &RedisClientSetXXFunc{ - defaultHook: func(context.Context, string, interface{}, time.Duration) *v9.BoolCmd { - panic("unexpected invocation of MockRedisClient.SetXX") - }, - }, - SortFunc: &RedisClientSortFunc{ - defaultHook: func(context.Context, string, *v9.Sort) *v9.StringSliceCmd { - panic("unexpected invocation of MockRedisClient.Sort") - }, - }, - SortInterfacesFunc: &RedisClientSortInterfacesFunc{ - defaultHook: func(context.Context, string, *v9.Sort) *v9.SliceCmd { - panic("unexpected invocation of MockRedisClient.SortInterfaces") - }, - }, - SortROFunc: &RedisClientSortROFunc{ - defaultHook: func(context.Context, string, *v9.Sort) *v9.StringSliceCmd { - panic("unexpected invocation of MockRedisClient.SortRO") - }, - }, - SortStoreFunc: &RedisClientSortStoreFunc{ - defaultHook: func(context.Context, string, string, *v9.Sort) *v9.IntCmd { - panic("unexpected invocation of MockRedisClient.SortStore") - }, - }, - StrLenFunc: &RedisClientStrLenFunc{ - defaultHook: func(context.Context, string) *v9.IntCmd { - panic("unexpected invocation of MockRedisClient.StrLen") - }, - }, - TTLFunc: &RedisClientTTLFunc{ - defaultHook: func(context.Context, string) *v9.DurationCmd { - panic("unexpected invocation of MockRedisClient.TTL") - }, - }, - TouchFunc: &RedisClientTouchFunc{ - defaultHook: func(context.Context, ...string) *v9.IntCmd { - panic("unexpected invocation of MockRedisClient.Touch") - }, - }, - TypeFunc: &RedisClientTypeFunc{ - defaultHook: func(context.Context, string) *v9.StatusCmd { - panic("unexpected invocation of MockRedisClient.Type") - }, - }, - } -} - -// NewMockRedisClientFrom creates a new mock of the MockRedisClient -// interface. All methods delegate to the given implementation, unless -// overwritten. -func NewMockRedisClientFrom(i RedisClient) *MockRedisClient { - return &MockRedisClient{ - AppendFunc: &RedisClientAppendFunc{ - defaultHook: i.Append, - }, - CopyFunc: &RedisClientCopyFunc{ - defaultHook: i.Copy, - }, - DecrFunc: &RedisClientDecrFunc{ - defaultHook: i.Decr, - }, - DecrByFunc: &RedisClientDecrByFunc{ - defaultHook: i.DecrBy, - }, - DelFunc: &RedisClientDelFunc{ - defaultHook: i.Del, - }, - DumpFunc: &RedisClientDumpFunc{ - defaultHook: i.Dump, - }, - ExistsFunc: &RedisClientExistsFunc{ - defaultHook: i.Exists, - }, - ExpireFunc: &RedisClientExpireFunc{ - defaultHook: i.Expire, - }, - ExpireAtFunc: &RedisClientExpireAtFunc{ - defaultHook: i.ExpireAt, - }, - ExpireGTFunc: &RedisClientExpireGTFunc{ - defaultHook: i.ExpireGT, - }, - ExpireLTFunc: &RedisClientExpireLTFunc{ - defaultHook: i.ExpireLT, - }, - ExpireNXFunc: &RedisClientExpireNXFunc{ - defaultHook: i.ExpireNX, - }, - ExpireTimeFunc: &RedisClientExpireTimeFunc{ - defaultHook: i.ExpireTime, - }, - ExpireXXFunc: &RedisClientExpireXXFunc{ - defaultHook: i.ExpireXX, - }, - GetFunc: &RedisClientGetFunc{ - defaultHook: i.Get, - }, - GetDelFunc: &RedisClientGetDelFunc{ - defaultHook: i.GetDel, - }, - GetExFunc: &RedisClientGetExFunc{ - defaultHook: i.GetEx, - }, - GetRangeFunc: &RedisClientGetRangeFunc{ - defaultHook: i.GetRange, - }, - GetSetFunc: &RedisClientGetSetFunc{ - defaultHook: i.GetSet, - }, - IncrFunc: &RedisClientIncrFunc{ - defaultHook: i.Incr, - }, - IncrByFunc: &RedisClientIncrByFunc{ - defaultHook: i.IncrBy, - }, - IncrByFloatFunc: &RedisClientIncrByFloatFunc{ - defaultHook: i.IncrByFloat, - }, - KeysFunc: &RedisClientKeysFunc{ - defaultHook: i.Keys, - }, - LCSFunc: &RedisClientLCSFunc{ - defaultHook: i.LCS, - }, - MGetFunc: &RedisClientMGetFunc{ - defaultHook: i.MGet, - }, - MSetFunc: &RedisClientMSetFunc{ - defaultHook: i.MSet, - }, - MSetNXFunc: &RedisClientMSetNXFunc{ - defaultHook: i.MSetNX, - }, - MigrateFunc: &RedisClientMigrateFunc{ - defaultHook: i.Migrate, - }, - MoveFunc: &RedisClientMoveFunc{ - defaultHook: i.Move, - }, - ObjectEncodingFunc: &RedisClientObjectEncodingFunc{ - defaultHook: i.ObjectEncoding, - }, - ObjectFreqFunc: &RedisClientObjectFreqFunc{ - defaultHook: i.ObjectFreq, - }, - ObjectIdleTimeFunc: &RedisClientObjectIdleTimeFunc{ - defaultHook: i.ObjectIdleTime, - }, - ObjectRefCountFunc: &RedisClientObjectRefCountFunc{ - defaultHook: i.ObjectRefCount, - }, - PExpireFunc: &RedisClientPExpireFunc{ - defaultHook: i.PExpire, - }, - PExpireAtFunc: &RedisClientPExpireAtFunc{ - defaultHook: i.PExpireAt, - }, - PExpireTimeFunc: &RedisClientPExpireTimeFunc{ - defaultHook: i.PExpireTime, - }, - PTTLFunc: &RedisClientPTTLFunc{ - defaultHook: i.PTTL, - }, - PersistFunc: &RedisClientPersistFunc{ - defaultHook: i.Persist, - }, - RandomKeyFunc: &RedisClientRandomKeyFunc{ - defaultHook: i.RandomKey, - }, - RenameFunc: &RedisClientRenameFunc{ - defaultHook: i.Rename, - }, - RenameNXFunc: &RedisClientRenameNXFunc{ - defaultHook: i.RenameNX, - }, - RestoreFunc: &RedisClientRestoreFunc{ - defaultHook: i.Restore, - }, - RestoreReplaceFunc: &RedisClientRestoreReplaceFunc{ - defaultHook: i.RestoreReplace, - }, - ScanFunc: &RedisClientScanFunc{ - defaultHook: i.Scan, - }, - ScanTypeFunc: &RedisClientScanTypeFunc{ - defaultHook: i.ScanType, - }, - SetFunc: &RedisClientSetFunc{ - defaultHook: i.Set, - }, - SetArgsFunc: &RedisClientSetArgsFunc{ - defaultHook: i.SetArgs, - }, - SetExFunc: &RedisClientSetExFunc{ - defaultHook: i.SetEx, - }, - SetNXFunc: &RedisClientSetNXFunc{ - defaultHook: i.SetNX, - }, - SetRangeFunc: &RedisClientSetRangeFunc{ - defaultHook: i.SetRange, - }, - SetXXFunc: &RedisClientSetXXFunc{ - defaultHook: i.SetXX, - }, - SortFunc: &RedisClientSortFunc{ - defaultHook: i.Sort, - }, - SortInterfacesFunc: &RedisClientSortInterfacesFunc{ - defaultHook: i.SortInterfaces, - }, - SortROFunc: &RedisClientSortROFunc{ - defaultHook: i.SortRO, - }, - SortStoreFunc: &RedisClientSortStoreFunc{ - defaultHook: i.SortStore, - }, - StrLenFunc: &RedisClientStrLenFunc{ - defaultHook: i.StrLen, - }, - TTLFunc: &RedisClientTTLFunc{ - defaultHook: i.TTL, - }, - TouchFunc: &RedisClientTouchFunc{ - defaultHook: i.Touch, - }, - TypeFunc: &RedisClientTypeFunc{ - defaultHook: i.Type, - }, - } -} - -// RedisClientAppendFunc describes the behavior when the Append method of -// the parent MockRedisClient instance is invoked. -type RedisClientAppendFunc struct { - defaultHook func(context.Context, string, string) *v9.IntCmd - hooks []func(context.Context, string, string) *v9.IntCmd - history []RedisClientAppendFuncCall - mutex sync.Mutex -} - -// Append delegates to the next hook function in the queue and stores the -// parameter and result values of this invocation. -func (m *MockRedisClient) Append(v0 context.Context, v1 string, v2 string) *v9.IntCmd { - r0 := m.AppendFunc.nextHook()(v0, v1, v2) - m.AppendFunc.appendCall(RedisClientAppendFuncCall{v0, v1, v2, r0}) - return r0 -} - -// SetDefaultHook sets function that is called when the Append method of the -// parent MockRedisClient instance is invoked and the hook queue is empty. -func (f *RedisClientAppendFunc) SetDefaultHook(hook func(context.Context, string, string) *v9.IntCmd) { - f.defaultHook = hook -} - -// PushHook adds a function to the end of hook queue. Each invocation of the -// Append method of the parent MockRedisClient instance invokes the hook at -// the front of the queue and discards it. After the queue is empty, the -// default hook function is invoked for any future action. -func (f *RedisClientAppendFunc) PushHook(hook func(context.Context, string, string) *v9.IntCmd) { - f.mutex.Lock() - f.hooks = append(f.hooks, hook) - f.mutex.Unlock() -} - -// SetDefaultReturn calls SetDefaultHook with a function that returns the -// given values. -func (f *RedisClientAppendFunc) SetDefaultReturn(r0 *v9.IntCmd) { - f.SetDefaultHook(func(context.Context, string, string) *v9.IntCmd { - return r0 - }) -} - -// PushReturn calls PushHook with a function that returns the given values. -func (f *RedisClientAppendFunc) PushReturn(r0 *v9.IntCmd) { - f.PushHook(func(context.Context, string, string) *v9.IntCmd { - return r0 - }) -} - -func (f *RedisClientAppendFunc) nextHook() func(context.Context, string, string) *v9.IntCmd { - f.mutex.Lock() - defer f.mutex.Unlock() - - if len(f.hooks) == 0 { - return f.defaultHook - } - - hook := f.hooks[0] - f.hooks = f.hooks[1:] - return hook -} - -func (f *RedisClientAppendFunc) appendCall(r0 RedisClientAppendFuncCall) { - f.mutex.Lock() - f.history = append(f.history, r0) - f.mutex.Unlock() -} - -// History returns a sequence of RedisClientAppendFuncCall objects -// describing the invocations of this function. -func (f *RedisClientAppendFunc) History() []RedisClientAppendFuncCall { - f.mutex.Lock() - history := make([]RedisClientAppendFuncCall, len(f.history)) - copy(history, f.history) - f.mutex.Unlock() - - return history -} - -// RedisClientAppendFuncCall is an object that describes an invocation of -// method Append on an instance of MockRedisClient. -type RedisClientAppendFuncCall struct { - // Arg0 is the value of the 1st argument passed to this method - // invocation. - Arg0 context.Context - // Arg1 is the value of the 2nd argument passed to this method - // invocation. - Arg1 string - // Arg2 is the value of the 3rd argument passed to this method - // invocation. - Arg2 string - // Result0 is the value of the 1st result returned from this method - // invocation. - Result0 *v9.IntCmd -} - -// Args returns an interface slice containing the arguments of this -// invocation. -func (c RedisClientAppendFuncCall) Args() []interface{} { - return []interface{}{c.Arg0, c.Arg1, c.Arg2} -} - -// Results returns an interface slice containing the results of this -// invocation. -func (c RedisClientAppendFuncCall) Results() []interface{} { - return []interface{}{c.Result0} -} - -// RedisClientCopyFunc describes the behavior when the Copy method of the -// parent MockRedisClient instance is invoked. -type RedisClientCopyFunc struct { - defaultHook func(context.Context, string, string, int, bool) *v9.IntCmd - hooks []func(context.Context, string, string, int, bool) *v9.IntCmd - history []RedisClientCopyFuncCall - mutex sync.Mutex -} - -// Copy delegates to the next hook function in the queue and stores the -// parameter and result values of this invocation. -func (m *MockRedisClient) Copy(v0 context.Context, v1 string, v2 string, v3 int, v4 bool) *v9.IntCmd { - r0 := m.CopyFunc.nextHook()(v0, v1, v2, v3, v4) - m.CopyFunc.appendCall(RedisClientCopyFuncCall{v0, v1, v2, v3, v4, r0}) - return r0 -} - -// SetDefaultHook sets function that is called when the Copy method of the -// parent MockRedisClient instance is invoked and the hook queue is empty. -func (f *RedisClientCopyFunc) SetDefaultHook(hook func(context.Context, string, string, int, bool) *v9.IntCmd) { - f.defaultHook = hook -} - -// PushHook adds a function to the end of hook queue. Each invocation of the -// Copy method of the parent MockRedisClient instance invokes the hook at -// the front of the queue and discards it. After the queue is empty, the -// default hook function is invoked for any future action. -func (f *RedisClientCopyFunc) PushHook(hook func(context.Context, string, string, int, bool) *v9.IntCmd) { - f.mutex.Lock() - f.hooks = append(f.hooks, hook) - f.mutex.Unlock() -} - -// SetDefaultReturn calls SetDefaultHook with a function that returns the -// given values. -func (f *RedisClientCopyFunc) SetDefaultReturn(r0 *v9.IntCmd) { - f.SetDefaultHook(func(context.Context, string, string, int, bool) *v9.IntCmd { - return r0 - }) -} - -// PushReturn calls PushHook with a function that returns the given values. -func (f *RedisClientCopyFunc) PushReturn(r0 *v9.IntCmd) { - f.PushHook(func(context.Context, string, string, int, bool) *v9.IntCmd { - return r0 - }) -} - -func (f *RedisClientCopyFunc) nextHook() func(context.Context, string, string, int, bool) *v9.IntCmd { - f.mutex.Lock() - defer f.mutex.Unlock() - - if len(f.hooks) == 0 { - return f.defaultHook - } - - hook := f.hooks[0] - f.hooks = f.hooks[1:] - return hook -} - -func (f *RedisClientCopyFunc) appendCall(r0 RedisClientCopyFuncCall) { - f.mutex.Lock() - f.history = append(f.history, r0) - f.mutex.Unlock() -} - -// History returns a sequence of RedisClientCopyFuncCall objects describing -// the invocations of this function. -func (f *RedisClientCopyFunc) History() []RedisClientCopyFuncCall { - f.mutex.Lock() - history := make([]RedisClientCopyFuncCall, len(f.history)) - copy(history, f.history) - f.mutex.Unlock() - - return history -} - -// RedisClientCopyFuncCall is an object that describes an invocation of -// method Copy on an instance of MockRedisClient. -type RedisClientCopyFuncCall struct { - // Arg0 is the value of the 1st argument passed to this method - // invocation. - Arg0 context.Context - // Arg1 is the value of the 2nd argument passed to this method - // invocation. - Arg1 string - // Arg2 is the value of the 3rd argument passed to this method - // invocation. - Arg2 string - // Arg3 is the value of the 4th argument passed to this method - // invocation. - Arg3 int - // Arg4 is the value of the 5th argument passed to this method - // invocation. - Arg4 bool - // Result0 is the value of the 1st result returned from this method - // invocation. - Result0 *v9.IntCmd -} - -// Args returns an interface slice containing the arguments of this -// invocation. -func (c RedisClientCopyFuncCall) Args() []interface{} { - return []interface{}{c.Arg0, c.Arg1, c.Arg2, c.Arg3, c.Arg4} -} - -// Results returns an interface slice containing the results of this -// invocation. -func (c RedisClientCopyFuncCall) Results() []interface{} { - return []interface{}{c.Result0} -} - -// RedisClientDecrFunc describes the behavior when the Decr method of the -// parent MockRedisClient instance is invoked. -type RedisClientDecrFunc struct { - defaultHook func(context.Context, string) *v9.IntCmd - hooks []func(context.Context, string) *v9.IntCmd - history []RedisClientDecrFuncCall - mutex sync.Mutex -} - -// Decr delegates to the next hook function in the queue and stores the -// parameter and result values of this invocation. -func (m *MockRedisClient) Decr(v0 context.Context, v1 string) *v9.IntCmd { - r0 := m.DecrFunc.nextHook()(v0, v1) - m.DecrFunc.appendCall(RedisClientDecrFuncCall{v0, v1, r0}) - return r0 -} - -// SetDefaultHook sets function that is called when the Decr method of the -// parent MockRedisClient instance is invoked and the hook queue is empty. -func (f *RedisClientDecrFunc) SetDefaultHook(hook func(context.Context, string) *v9.IntCmd) { - f.defaultHook = hook -} - -// PushHook adds a function to the end of hook queue. Each invocation of the -// Decr method of the parent MockRedisClient instance invokes the hook at -// the front of the queue and discards it. After the queue is empty, the -// default hook function is invoked for any future action. -func (f *RedisClientDecrFunc) PushHook(hook func(context.Context, string) *v9.IntCmd) { - f.mutex.Lock() - f.hooks = append(f.hooks, hook) - f.mutex.Unlock() -} - -// SetDefaultReturn calls SetDefaultHook with a function that returns the -// given values. -func (f *RedisClientDecrFunc) SetDefaultReturn(r0 *v9.IntCmd) { - f.SetDefaultHook(func(context.Context, string) *v9.IntCmd { - return r0 - }) -} - -// PushReturn calls PushHook with a function that returns the given values. -func (f *RedisClientDecrFunc) PushReturn(r0 *v9.IntCmd) { - f.PushHook(func(context.Context, string) *v9.IntCmd { - return r0 - }) -} - -func (f *RedisClientDecrFunc) nextHook() func(context.Context, string) *v9.IntCmd { - f.mutex.Lock() - defer f.mutex.Unlock() - - if len(f.hooks) == 0 { - return f.defaultHook - } - - hook := f.hooks[0] - f.hooks = f.hooks[1:] - return hook -} - -func (f *RedisClientDecrFunc) appendCall(r0 RedisClientDecrFuncCall) { - f.mutex.Lock() - f.history = append(f.history, r0) - f.mutex.Unlock() -} - -// History returns a sequence of RedisClientDecrFuncCall objects describing -// the invocations of this function. -func (f *RedisClientDecrFunc) History() []RedisClientDecrFuncCall { - f.mutex.Lock() - history := make([]RedisClientDecrFuncCall, len(f.history)) - copy(history, f.history) - f.mutex.Unlock() - - return history -} - -// RedisClientDecrFuncCall is an object that describes an invocation of -// method Decr on an instance of MockRedisClient. -type RedisClientDecrFuncCall struct { - // Arg0 is the value of the 1st argument passed to this method - // invocation. - Arg0 context.Context - // Arg1 is the value of the 2nd argument passed to this method - // invocation. - Arg1 string - // Result0 is the value of the 1st result returned from this method - // invocation. - Result0 *v9.IntCmd -} - -// Args returns an interface slice containing the arguments of this -// invocation. -func (c RedisClientDecrFuncCall) Args() []interface{} { - return []interface{}{c.Arg0, c.Arg1} -} - -// Results returns an interface slice containing the results of this -// invocation. -func (c RedisClientDecrFuncCall) Results() []interface{} { - return []interface{}{c.Result0} -} - -// RedisClientDecrByFunc describes the behavior when the DecrBy method of -// the parent MockRedisClient instance is invoked. -type RedisClientDecrByFunc struct { - defaultHook func(context.Context, string, int64) *v9.IntCmd - hooks []func(context.Context, string, int64) *v9.IntCmd - history []RedisClientDecrByFuncCall - mutex sync.Mutex -} - -// DecrBy delegates to the next hook function in the queue and stores the -// parameter and result values of this invocation. -func (m *MockRedisClient) DecrBy(v0 context.Context, v1 string, v2 int64) *v9.IntCmd { - r0 := m.DecrByFunc.nextHook()(v0, v1, v2) - m.DecrByFunc.appendCall(RedisClientDecrByFuncCall{v0, v1, v2, r0}) - return r0 -} - -// SetDefaultHook sets function that is called when the DecrBy method of the -// parent MockRedisClient instance is invoked and the hook queue is empty. -func (f *RedisClientDecrByFunc) SetDefaultHook(hook func(context.Context, string, int64) *v9.IntCmd) { - f.defaultHook = hook -} - -// PushHook adds a function to the end of hook queue. Each invocation of the -// DecrBy method of the parent MockRedisClient instance invokes the hook at -// the front of the queue and discards it. After the queue is empty, the -// default hook function is invoked for any future action. -func (f *RedisClientDecrByFunc) PushHook(hook func(context.Context, string, int64) *v9.IntCmd) { - f.mutex.Lock() - f.hooks = append(f.hooks, hook) - f.mutex.Unlock() -} - -// SetDefaultReturn calls SetDefaultHook with a function that returns the -// given values. -func (f *RedisClientDecrByFunc) SetDefaultReturn(r0 *v9.IntCmd) { - f.SetDefaultHook(func(context.Context, string, int64) *v9.IntCmd { - return r0 - }) -} - -// PushReturn calls PushHook with a function that returns the given values. -func (f *RedisClientDecrByFunc) PushReturn(r0 *v9.IntCmd) { - f.PushHook(func(context.Context, string, int64) *v9.IntCmd { - return r0 - }) -} - -func (f *RedisClientDecrByFunc) nextHook() func(context.Context, string, int64) *v9.IntCmd { - f.mutex.Lock() - defer f.mutex.Unlock() - - if len(f.hooks) == 0 { - return f.defaultHook - } - - hook := f.hooks[0] - f.hooks = f.hooks[1:] - return hook -} - -func (f *RedisClientDecrByFunc) appendCall(r0 RedisClientDecrByFuncCall) { - f.mutex.Lock() - f.history = append(f.history, r0) - f.mutex.Unlock() -} - -// History returns a sequence of RedisClientDecrByFuncCall objects -// describing the invocations of this function. -func (f *RedisClientDecrByFunc) History() []RedisClientDecrByFuncCall { - f.mutex.Lock() - history := make([]RedisClientDecrByFuncCall, len(f.history)) - copy(history, f.history) - f.mutex.Unlock() - - return history -} - -// RedisClientDecrByFuncCall is an object that describes an invocation of -// method DecrBy on an instance of MockRedisClient. -type RedisClientDecrByFuncCall struct { - // Arg0 is the value of the 1st argument passed to this method - // invocation. - Arg0 context.Context - // Arg1 is the value of the 2nd argument passed to this method - // invocation. - Arg1 string - // Arg2 is the value of the 3rd argument passed to this method - // invocation. - Arg2 int64 - // Result0 is the value of the 1st result returned from this method - // invocation. - Result0 *v9.IntCmd -} - -// Args returns an interface slice containing the arguments of this -// invocation. -func (c RedisClientDecrByFuncCall) Args() []interface{} { - return []interface{}{c.Arg0, c.Arg1, c.Arg2} -} - -// Results returns an interface slice containing the results of this -// invocation. -func (c RedisClientDecrByFuncCall) Results() []interface{} { - return []interface{}{c.Result0} -} - -// RedisClientDelFunc describes the behavior when the Del method of the -// parent MockRedisClient instance is invoked. -type RedisClientDelFunc struct { - defaultHook func(context.Context, ...string) *v9.IntCmd - hooks []func(context.Context, ...string) *v9.IntCmd - history []RedisClientDelFuncCall - mutex sync.Mutex -} - -// Del delegates to the next hook function in the queue and stores the -// parameter and result values of this invocation. -func (m *MockRedisClient) Del(v0 context.Context, v1 ...string) *v9.IntCmd { - r0 := m.DelFunc.nextHook()(v0, v1...) - m.DelFunc.appendCall(RedisClientDelFuncCall{v0, v1, r0}) - return r0 -} - -// SetDefaultHook sets function that is called when the Del method of the -// parent MockRedisClient instance is invoked and the hook queue is empty. -func (f *RedisClientDelFunc) SetDefaultHook(hook func(context.Context, ...string) *v9.IntCmd) { - f.defaultHook = hook -} - -// PushHook adds a function to the end of hook queue. Each invocation of the -// Del method of the parent MockRedisClient instance invokes the hook at the -// front of the queue and discards it. After the queue is empty, the default -// hook function is invoked for any future action. -func (f *RedisClientDelFunc) PushHook(hook func(context.Context, ...string) *v9.IntCmd) { - f.mutex.Lock() - f.hooks = append(f.hooks, hook) - f.mutex.Unlock() -} - -// SetDefaultReturn calls SetDefaultHook with a function that returns the -// given values. -func (f *RedisClientDelFunc) SetDefaultReturn(r0 *v9.IntCmd) { - f.SetDefaultHook(func(context.Context, ...string) *v9.IntCmd { - return r0 - }) -} - -// PushReturn calls PushHook with a function that returns the given values. -func (f *RedisClientDelFunc) PushReturn(r0 *v9.IntCmd) { - f.PushHook(func(context.Context, ...string) *v9.IntCmd { - return r0 - }) -} - -func (f *RedisClientDelFunc) nextHook() func(context.Context, ...string) *v9.IntCmd { - f.mutex.Lock() - defer f.mutex.Unlock() - - if len(f.hooks) == 0 { - return f.defaultHook - } - - hook := f.hooks[0] - f.hooks = f.hooks[1:] - return hook -} - -func (f *RedisClientDelFunc) appendCall(r0 RedisClientDelFuncCall) { - f.mutex.Lock() - f.history = append(f.history, r0) - f.mutex.Unlock() -} - -// History returns a sequence of RedisClientDelFuncCall objects describing -// the invocations of this function. -func (f *RedisClientDelFunc) History() []RedisClientDelFuncCall { - f.mutex.Lock() - history := make([]RedisClientDelFuncCall, len(f.history)) - copy(history, f.history) - f.mutex.Unlock() - - return history -} - -// RedisClientDelFuncCall is an object that describes an invocation of -// method Del on an instance of MockRedisClient. -type RedisClientDelFuncCall struct { - // Arg0 is the value of the 1st argument passed to this method - // invocation. - Arg0 context.Context - // Arg1 is a slice containing the values of the variadic arguments - // passed to this method invocation. - Arg1 []string - // Result0 is the value of the 1st result returned from this method - // invocation. - Result0 *v9.IntCmd -} - -// Args returns an interface slice containing the arguments of this -// invocation. The variadic slice argument is flattened in this array such -// that one positional argument and three variadic arguments would result in -// a slice of four, not two. -func (c RedisClientDelFuncCall) Args() []interface{} { - trailing := []interface{}{} - for _, val := range c.Arg1 { - trailing = append(trailing, val) - } - - return append([]interface{}{c.Arg0}, trailing...) -} - -// Results returns an interface slice containing the results of this -// invocation. -func (c RedisClientDelFuncCall) Results() []interface{} { - return []interface{}{c.Result0} -} - -// RedisClientDumpFunc describes the behavior when the Dump method of the -// parent MockRedisClient instance is invoked. -type RedisClientDumpFunc struct { - defaultHook func(context.Context, string) *v9.StringCmd - hooks []func(context.Context, string) *v9.StringCmd - history []RedisClientDumpFuncCall - mutex sync.Mutex -} - -// Dump delegates to the next hook function in the queue and stores the -// parameter and result values of this invocation. -func (m *MockRedisClient) Dump(v0 context.Context, v1 string) *v9.StringCmd { - r0 := m.DumpFunc.nextHook()(v0, v1) - m.DumpFunc.appendCall(RedisClientDumpFuncCall{v0, v1, r0}) - return r0 -} - -// SetDefaultHook sets function that is called when the Dump method of the -// parent MockRedisClient instance is invoked and the hook queue is empty. -func (f *RedisClientDumpFunc) SetDefaultHook(hook func(context.Context, string) *v9.StringCmd) { - f.defaultHook = hook -} - -// PushHook adds a function to the end of hook queue. Each invocation of the -// Dump method of the parent MockRedisClient instance invokes the hook at -// the front of the queue and discards it. After the queue is empty, the -// default hook function is invoked for any future action. -func (f *RedisClientDumpFunc) PushHook(hook func(context.Context, string) *v9.StringCmd) { - f.mutex.Lock() - f.hooks = append(f.hooks, hook) - f.mutex.Unlock() -} - -// SetDefaultReturn calls SetDefaultHook with a function that returns the -// given values. -func (f *RedisClientDumpFunc) SetDefaultReturn(r0 *v9.StringCmd) { - f.SetDefaultHook(func(context.Context, string) *v9.StringCmd { - return r0 - }) -} - -// PushReturn calls PushHook with a function that returns the given values. -func (f *RedisClientDumpFunc) PushReturn(r0 *v9.StringCmd) { - f.PushHook(func(context.Context, string) *v9.StringCmd { - return r0 - }) -} - -func (f *RedisClientDumpFunc) nextHook() func(context.Context, string) *v9.StringCmd { - f.mutex.Lock() - defer f.mutex.Unlock() - - if len(f.hooks) == 0 { - return f.defaultHook - } - - hook := f.hooks[0] - f.hooks = f.hooks[1:] - return hook -} - -func (f *RedisClientDumpFunc) appendCall(r0 RedisClientDumpFuncCall) { - f.mutex.Lock() - f.history = append(f.history, r0) - f.mutex.Unlock() -} - -// History returns a sequence of RedisClientDumpFuncCall objects describing -// the invocations of this function. -func (f *RedisClientDumpFunc) History() []RedisClientDumpFuncCall { - f.mutex.Lock() - history := make([]RedisClientDumpFuncCall, len(f.history)) - copy(history, f.history) - f.mutex.Unlock() - - return history -} - -// RedisClientDumpFuncCall is an object that describes an invocation of -// method Dump on an instance of MockRedisClient. -type RedisClientDumpFuncCall struct { - // Arg0 is the value of the 1st argument passed to this method - // invocation. - Arg0 context.Context - // Arg1 is the value of the 2nd argument passed to this method - // invocation. - Arg1 string - // Result0 is the value of the 1st result returned from this method - // invocation. - Result0 *v9.StringCmd -} - -// Args returns an interface slice containing the arguments of this -// invocation. -func (c RedisClientDumpFuncCall) Args() []interface{} { - return []interface{}{c.Arg0, c.Arg1} -} - -// Results returns an interface slice containing the results of this -// invocation. -func (c RedisClientDumpFuncCall) Results() []interface{} { - return []interface{}{c.Result0} -} - -// RedisClientExistsFunc describes the behavior when the Exists method of -// the parent MockRedisClient instance is invoked. -type RedisClientExistsFunc struct { - defaultHook func(context.Context, ...string) *v9.IntCmd - hooks []func(context.Context, ...string) *v9.IntCmd - history []RedisClientExistsFuncCall - mutex sync.Mutex -} - -// Exists delegates to the next hook function in the queue and stores the -// parameter and result values of this invocation. -func (m *MockRedisClient) Exists(v0 context.Context, v1 ...string) *v9.IntCmd { - r0 := m.ExistsFunc.nextHook()(v0, v1...) - m.ExistsFunc.appendCall(RedisClientExistsFuncCall{v0, v1, r0}) - return r0 -} - -// SetDefaultHook sets function that is called when the Exists method of the -// parent MockRedisClient instance is invoked and the hook queue is empty. -func (f *RedisClientExistsFunc) SetDefaultHook(hook func(context.Context, ...string) *v9.IntCmd) { - f.defaultHook = hook -} - -// PushHook adds a function to the end of hook queue. Each invocation of the -// Exists method of the parent MockRedisClient instance invokes the hook at -// the front of the queue and discards it. After the queue is empty, the -// default hook function is invoked for any future action. -func (f *RedisClientExistsFunc) PushHook(hook func(context.Context, ...string) *v9.IntCmd) { - f.mutex.Lock() - f.hooks = append(f.hooks, hook) - f.mutex.Unlock() -} - -// SetDefaultReturn calls SetDefaultHook with a function that returns the -// given values. -func (f *RedisClientExistsFunc) SetDefaultReturn(r0 *v9.IntCmd) { - f.SetDefaultHook(func(context.Context, ...string) *v9.IntCmd { - return r0 - }) -} - -// PushReturn calls PushHook with a function that returns the given values. -func (f *RedisClientExistsFunc) PushReturn(r0 *v9.IntCmd) { - f.PushHook(func(context.Context, ...string) *v9.IntCmd { - return r0 - }) -} - -func (f *RedisClientExistsFunc) nextHook() func(context.Context, ...string) *v9.IntCmd { - f.mutex.Lock() - defer f.mutex.Unlock() - - if len(f.hooks) == 0 { - return f.defaultHook - } - - hook := f.hooks[0] - f.hooks = f.hooks[1:] - return hook -} - -func (f *RedisClientExistsFunc) appendCall(r0 RedisClientExistsFuncCall) { - f.mutex.Lock() - f.history = append(f.history, r0) - f.mutex.Unlock() -} - -// History returns a sequence of RedisClientExistsFuncCall objects -// describing the invocations of this function. -func (f *RedisClientExistsFunc) History() []RedisClientExistsFuncCall { - f.mutex.Lock() - history := make([]RedisClientExistsFuncCall, len(f.history)) - copy(history, f.history) - f.mutex.Unlock() - - return history -} - -// RedisClientExistsFuncCall is an object that describes an invocation of -// method Exists on an instance of MockRedisClient. -type RedisClientExistsFuncCall struct { - // Arg0 is the value of the 1st argument passed to this method - // invocation. - Arg0 context.Context - // Arg1 is a slice containing the values of the variadic arguments - // passed to this method invocation. - Arg1 []string - // Result0 is the value of the 1st result returned from this method - // invocation. - Result0 *v9.IntCmd -} - -// Args returns an interface slice containing the arguments of this -// invocation. The variadic slice argument is flattened in this array such -// that one positional argument and three variadic arguments would result in -// a slice of four, not two. -func (c RedisClientExistsFuncCall) Args() []interface{} { - trailing := []interface{}{} - for _, val := range c.Arg1 { - trailing = append(trailing, val) - } - - return append([]interface{}{c.Arg0}, trailing...) -} - -// Results returns an interface slice containing the results of this -// invocation. -func (c RedisClientExistsFuncCall) Results() []interface{} { - return []interface{}{c.Result0} -} - -// RedisClientExpireFunc describes the behavior when the Expire method of -// the parent MockRedisClient instance is invoked. -type RedisClientExpireFunc struct { - defaultHook func(context.Context, string, time.Duration) *v9.BoolCmd - hooks []func(context.Context, string, time.Duration) *v9.BoolCmd - history []RedisClientExpireFuncCall - mutex sync.Mutex -} - -// Expire delegates to the next hook function in the queue and stores the -// parameter and result values of this invocation. -func (m *MockRedisClient) Expire(v0 context.Context, v1 string, v2 time.Duration) *v9.BoolCmd { - r0 := m.ExpireFunc.nextHook()(v0, v1, v2) - m.ExpireFunc.appendCall(RedisClientExpireFuncCall{v0, v1, v2, r0}) - return r0 -} - -// SetDefaultHook sets function that is called when the Expire method of the -// parent MockRedisClient instance is invoked and the hook queue is empty. -func (f *RedisClientExpireFunc) SetDefaultHook(hook func(context.Context, string, time.Duration) *v9.BoolCmd) { - f.defaultHook = hook -} - -// PushHook adds a function to the end of hook queue. Each invocation of the -// Expire method of the parent MockRedisClient instance invokes the hook at -// the front of the queue and discards it. After the queue is empty, the -// default hook function is invoked for any future action. -func (f *RedisClientExpireFunc) PushHook(hook func(context.Context, string, time.Duration) *v9.BoolCmd) { - f.mutex.Lock() - f.hooks = append(f.hooks, hook) - f.mutex.Unlock() -} - -// SetDefaultReturn calls SetDefaultHook with a function that returns the -// given values. -func (f *RedisClientExpireFunc) SetDefaultReturn(r0 *v9.BoolCmd) { - f.SetDefaultHook(func(context.Context, string, time.Duration) *v9.BoolCmd { - return r0 - }) -} - -// PushReturn calls PushHook with a function that returns the given values. -func (f *RedisClientExpireFunc) PushReturn(r0 *v9.BoolCmd) { - f.PushHook(func(context.Context, string, time.Duration) *v9.BoolCmd { - return r0 - }) -} - -func (f *RedisClientExpireFunc) nextHook() func(context.Context, string, time.Duration) *v9.BoolCmd { - f.mutex.Lock() - defer f.mutex.Unlock() - - if len(f.hooks) == 0 { - return f.defaultHook - } - - hook := f.hooks[0] - f.hooks = f.hooks[1:] - return hook -} - -func (f *RedisClientExpireFunc) appendCall(r0 RedisClientExpireFuncCall) { - f.mutex.Lock() - f.history = append(f.history, r0) - f.mutex.Unlock() -} - -// History returns a sequence of RedisClientExpireFuncCall objects -// describing the invocations of this function. -func (f *RedisClientExpireFunc) History() []RedisClientExpireFuncCall { - f.mutex.Lock() - history := make([]RedisClientExpireFuncCall, len(f.history)) - copy(history, f.history) - f.mutex.Unlock() - - return history -} - -// RedisClientExpireFuncCall is an object that describes an invocation of -// method Expire on an instance of MockRedisClient. -type RedisClientExpireFuncCall struct { - // Arg0 is the value of the 1st argument passed to this method - // invocation. - Arg0 context.Context - // Arg1 is the value of the 2nd argument passed to this method - // invocation. - Arg1 string - // Arg2 is the value of the 3rd argument passed to this method - // invocation. - Arg2 time.Duration - // Result0 is the value of the 1st result returned from this method - // invocation. - Result0 *v9.BoolCmd -} - -// Args returns an interface slice containing the arguments of this -// invocation. -func (c RedisClientExpireFuncCall) Args() []interface{} { - return []interface{}{c.Arg0, c.Arg1, c.Arg2} -} - -// Results returns an interface slice containing the results of this -// invocation. -func (c RedisClientExpireFuncCall) Results() []interface{} { - return []interface{}{c.Result0} -} - -// RedisClientExpireAtFunc describes the behavior when the ExpireAt method -// of the parent MockRedisClient instance is invoked. -type RedisClientExpireAtFunc struct { - defaultHook func(context.Context, string, time.Time) *v9.BoolCmd - hooks []func(context.Context, string, time.Time) *v9.BoolCmd - history []RedisClientExpireAtFuncCall - mutex sync.Mutex -} - -// ExpireAt delegates to the next hook function in the queue and stores the -// parameter and result values of this invocation. -func (m *MockRedisClient) ExpireAt(v0 context.Context, v1 string, v2 time.Time) *v9.BoolCmd { - r0 := m.ExpireAtFunc.nextHook()(v0, v1, v2) - m.ExpireAtFunc.appendCall(RedisClientExpireAtFuncCall{v0, v1, v2, r0}) - return r0 -} - -// SetDefaultHook sets function that is called when the ExpireAt method of -// the parent MockRedisClient instance is invoked and the hook queue is -// empty. -func (f *RedisClientExpireAtFunc) SetDefaultHook(hook func(context.Context, string, time.Time) *v9.BoolCmd) { - f.defaultHook = hook -} - -// PushHook adds a function to the end of hook queue. Each invocation of the -// ExpireAt method of the parent MockRedisClient instance invokes the hook -// at the front of the queue and discards it. After the queue is empty, the -// default hook function is invoked for any future action. -func (f *RedisClientExpireAtFunc) PushHook(hook func(context.Context, string, time.Time) *v9.BoolCmd) { - f.mutex.Lock() - f.hooks = append(f.hooks, hook) - f.mutex.Unlock() -} - -// SetDefaultReturn calls SetDefaultHook with a function that returns the -// given values. -func (f *RedisClientExpireAtFunc) SetDefaultReturn(r0 *v9.BoolCmd) { - f.SetDefaultHook(func(context.Context, string, time.Time) *v9.BoolCmd { - return r0 - }) -} - -// PushReturn calls PushHook with a function that returns the given values. -func (f *RedisClientExpireAtFunc) PushReturn(r0 *v9.BoolCmd) { - f.PushHook(func(context.Context, string, time.Time) *v9.BoolCmd { - return r0 - }) -} - -func (f *RedisClientExpireAtFunc) nextHook() func(context.Context, string, time.Time) *v9.BoolCmd { - f.mutex.Lock() - defer f.mutex.Unlock() - - if len(f.hooks) == 0 { - return f.defaultHook - } - - hook := f.hooks[0] - f.hooks = f.hooks[1:] - return hook -} - -func (f *RedisClientExpireAtFunc) appendCall(r0 RedisClientExpireAtFuncCall) { - f.mutex.Lock() - f.history = append(f.history, r0) - f.mutex.Unlock() -} - -// History returns a sequence of RedisClientExpireAtFuncCall objects -// describing the invocations of this function. -func (f *RedisClientExpireAtFunc) History() []RedisClientExpireAtFuncCall { - f.mutex.Lock() - history := make([]RedisClientExpireAtFuncCall, len(f.history)) - copy(history, f.history) - f.mutex.Unlock() - - return history -} - -// RedisClientExpireAtFuncCall is an object that describes an invocation of -// method ExpireAt on an instance of MockRedisClient. -type RedisClientExpireAtFuncCall struct { - // Arg0 is the value of the 1st argument passed to this method - // invocation. - Arg0 context.Context - // Arg1 is the value of the 2nd argument passed to this method - // invocation. - Arg1 string - // Arg2 is the value of the 3rd argument passed to this method - // invocation. - Arg2 time.Time - // Result0 is the value of the 1st result returned from this method - // invocation. - Result0 *v9.BoolCmd -} - -// Args returns an interface slice containing the arguments of this -// invocation. -func (c RedisClientExpireAtFuncCall) Args() []interface{} { - return []interface{}{c.Arg0, c.Arg1, c.Arg2} -} - -// Results returns an interface slice containing the results of this -// invocation. -func (c RedisClientExpireAtFuncCall) Results() []interface{} { - return []interface{}{c.Result0} -} - -// RedisClientExpireGTFunc describes the behavior when the ExpireGT method -// of the parent MockRedisClient instance is invoked. -type RedisClientExpireGTFunc struct { - defaultHook func(context.Context, string, time.Duration) *v9.BoolCmd - hooks []func(context.Context, string, time.Duration) *v9.BoolCmd - history []RedisClientExpireGTFuncCall - mutex sync.Mutex -} - -// ExpireGT delegates to the next hook function in the queue and stores the -// parameter and result values of this invocation. -func (m *MockRedisClient) ExpireGT(v0 context.Context, v1 string, v2 time.Duration) *v9.BoolCmd { - r0 := m.ExpireGTFunc.nextHook()(v0, v1, v2) - m.ExpireGTFunc.appendCall(RedisClientExpireGTFuncCall{v0, v1, v2, r0}) - return r0 -} - -// SetDefaultHook sets function that is called when the ExpireGT method of -// the parent MockRedisClient instance is invoked and the hook queue is -// empty. -func (f *RedisClientExpireGTFunc) SetDefaultHook(hook func(context.Context, string, time.Duration) *v9.BoolCmd) { - f.defaultHook = hook -} - -// PushHook adds a function to the end of hook queue. Each invocation of the -// ExpireGT method of the parent MockRedisClient instance invokes the hook -// at the front of the queue and discards it. After the queue is empty, the -// default hook function is invoked for any future action. -func (f *RedisClientExpireGTFunc) PushHook(hook func(context.Context, string, time.Duration) *v9.BoolCmd) { - f.mutex.Lock() - f.hooks = append(f.hooks, hook) - f.mutex.Unlock() -} - -// SetDefaultReturn calls SetDefaultHook with a function that returns the -// given values. -func (f *RedisClientExpireGTFunc) SetDefaultReturn(r0 *v9.BoolCmd) { - f.SetDefaultHook(func(context.Context, string, time.Duration) *v9.BoolCmd { - return r0 - }) -} - -// PushReturn calls PushHook with a function that returns the given values. -func (f *RedisClientExpireGTFunc) PushReturn(r0 *v9.BoolCmd) { - f.PushHook(func(context.Context, string, time.Duration) *v9.BoolCmd { - return r0 - }) -} - -func (f *RedisClientExpireGTFunc) nextHook() func(context.Context, string, time.Duration) *v9.BoolCmd { - f.mutex.Lock() - defer f.mutex.Unlock() - - if len(f.hooks) == 0 { - return f.defaultHook - } - - hook := f.hooks[0] - f.hooks = f.hooks[1:] - return hook -} - -func (f *RedisClientExpireGTFunc) appendCall(r0 RedisClientExpireGTFuncCall) { - f.mutex.Lock() - f.history = append(f.history, r0) - f.mutex.Unlock() -} - -// History returns a sequence of RedisClientExpireGTFuncCall objects -// describing the invocations of this function. -func (f *RedisClientExpireGTFunc) History() []RedisClientExpireGTFuncCall { - f.mutex.Lock() - history := make([]RedisClientExpireGTFuncCall, len(f.history)) - copy(history, f.history) - f.mutex.Unlock() - - return history -} - -// RedisClientExpireGTFuncCall is an object that describes an invocation of -// method ExpireGT on an instance of MockRedisClient. -type RedisClientExpireGTFuncCall struct { - // Arg0 is the value of the 1st argument passed to this method - // invocation. - Arg0 context.Context - // Arg1 is the value of the 2nd argument passed to this method - // invocation. - Arg1 string - // Arg2 is the value of the 3rd argument passed to this method - // invocation. - Arg2 time.Duration - // Result0 is the value of the 1st result returned from this method - // invocation. - Result0 *v9.BoolCmd -} - -// Args returns an interface slice containing the arguments of this -// invocation. -func (c RedisClientExpireGTFuncCall) Args() []interface{} { - return []interface{}{c.Arg0, c.Arg1, c.Arg2} -} - -// Results returns an interface slice containing the results of this -// invocation. -func (c RedisClientExpireGTFuncCall) Results() []interface{} { - return []interface{}{c.Result0} -} - -// RedisClientExpireLTFunc describes the behavior when the ExpireLT method -// of the parent MockRedisClient instance is invoked. -type RedisClientExpireLTFunc struct { - defaultHook func(context.Context, string, time.Duration) *v9.BoolCmd - hooks []func(context.Context, string, time.Duration) *v9.BoolCmd - history []RedisClientExpireLTFuncCall - mutex sync.Mutex -} - -// ExpireLT delegates to the next hook function in the queue and stores the -// parameter and result values of this invocation. -func (m *MockRedisClient) ExpireLT(v0 context.Context, v1 string, v2 time.Duration) *v9.BoolCmd { - r0 := m.ExpireLTFunc.nextHook()(v0, v1, v2) - m.ExpireLTFunc.appendCall(RedisClientExpireLTFuncCall{v0, v1, v2, r0}) - return r0 -} - -// SetDefaultHook sets function that is called when the ExpireLT method of -// the parent MockRedisClient instance is invoked and the hook queue is -// empty. -func (f *RedisClientExpireLTFunc) SetDefaultHook(hook func(context.Context, string, time.Duration) *v9.BoolCmd) { - f.defaultHook = hook -} - -// PushHook adds a function to the end of hook queue. Each invocation of the -// ExpireLT method of the parent MockRedisClient instance invokes the hook -// at the front of the queue and discards it. After the queue is empty, the -// default hook function is invoked for any future action. -func (f *RedisClientExpireLTFunc) PushHook(hook func(context.Context, string, time.Duration) *v9.BoolCmd) { - f.mutex.Lock() - f.hooks = append(f.hooks, hook) - f.mutex.Unlock() -} - -// SetDefaultReturn calls SetDefaultHook with a function that returns the -// given values. -func (f *RedisClientExpireLTFunc) SetDefaultReturn(r0 *v9.BoolCmd) { - f.SetDefaultHook(func(context.Context, string, time.Duration) *v9.BoolCmd { - return r0 - }) -} - -// PushReturn calls PushHook with a function that returns the given values. -func (f *RedisClientExpireLTFunc) PushReturn(r0 *v9.BoolCmd) { - f.PushHook(func(context.Context, string, time.Duration) *v9.BoolCmd { - return r0 - }) -} - -func (f *RedisClientExpireLTFunc) nextHook() func(context.Context, string, time.Duration) *v9.BoolCmd { - f.mutex.Lock() - defer f.mutex.Unlock() - - if len(f.hooks) == 0 { - return f.defaultHook - } - - hook := f.hooks[0] - f.hooks = f.hooks[1:] - return hook -} - -func (f *RedisClientExpireLTFunc) appendCall(r0 RedisClientExpireLTFuncCall) { - f.mutex.Lock() - f.history = append(f.history, r0) - f.mutex.Unlock() -} - -// History returns a sequence of RedisClientExpireLTFuncCall objects -// describing the invocations of this function. -func (f *RedisClientExpireLTFunc) History() []RedisClientExpireLTFuncCall { - f.mutex.Lock() - history := make([]RedisClientExpireLTFuncCall, len(f.history)) - copy(history, f.history) - f.mutex.Unlock() - - return history -} - -// RedisClientExpireLTFuncCall is an object that describes an invocation of -// method ExpireLT on an instance of MockRedisClient. -type RedisClientExpireLTFuncCall struct { - // Arg0 is the value of the 1st argument passed to this method - // invocation. - Arg0 context.Context - // Arg1 is the value of the 2nd argument passed to this method - // invocation. - Arg1 string - // Arg2 is the value of the 3rd argument passed to this method - // invocation. - Arg2 time.Duration - // Result0 is the value of the 1st result returned from this method - // invocation. - Result0 *v9.BoolCmd -} - -// Args returns an interface slice containing the arguments of this -// invocation. -func (c RedisClientExpireLTFuncCall) Args() []interface{} { - return []interface{}{c.Arg0, c.Arg1, c.Arg2} -} - -// Results returns an interface slice containing the results of this -// invocation. -func (c RedisClientExpireLTFuncCall) Results() []interface{} { - return []interface{}{c.Result0} -} - -// RedisClientExpireNXFunc describes the behavior when the ExpireNX method -// of the parent MockRedisClient instance is invoked. -type RedisClientExpireNXFunc struct { - defaultHook func(context.Context, string, time.Duration) *v9.BoolCmd - hooks []func(context.Context, string, time.Duration) *v9.BoolCmd - history []RedisClientExpireNXFuncCall - mutex sync.Mutex -} - -// ExpireNX delegates to the next hook function in the queue and stores the -// parameter and result values of this invocation. -func (m *MockRedisClient) ExpireNX(v0 context.Context, v1 string, v2 time.Duration) *v9.BoolCmd { - r0 := m.ExpireNXFunc.nextHook()(v0, v1, v2) - m.ExpireNXFunc.appendCall(RedisClientExpireNXFuncCall{v0, v1, v2, r0}) - return r0 -} - -// SetDefaultHook sets function that is called when the ExpireNX method of -// the parent MockRedisClient instance is invoked and the hook queue is -// empty. -func (f *RedisClientExpireNXFunc) SetDefaultHook(hook func(context.Context, string, time.Duration) *v9.BoolCmd) { - f.defaultHook = hook -} - -// PushHook adds a function to the end of hook queue. Each invocation of the -// ExpireNX method of the parent MockRedisClient instance invokes the hook -// at the front of the queue and discards it. After the queue is empty, the -// default hook function is invoked for any future action. -func (f *RedisClientExpireNXFunc) PushHook(hook func(context.Context, string, time.Duration) *v9.BoolCmd) { - f.mutex.Lock() - f.hooks = append(f.hooks, hook) - f.mutex.Unlock() -} - -// SetDefaultReturn calls SetDefaultHook with a function that returns the -// given values. -func (f *RedisClientExpireNXFunc) SetDefaultReturn(r0 *v9.BoolCmd) { - f.SetDefaultHook(func(context.Context, string, time.Duration) *v9.BoolCmd { - return r0 - }) -} - -// PushReturn calls PushHook with a function that returns the given values. -func (f *RedisClientExpireNXFunc) PushReturn(r0 *v9.BoolCmd) { - f.PushHook(func(context.Context, string, time.Duration) *v9.BoolCmd { - return r0 - }) -} - -func (f *RedisClientExpireNXFunc) nextHook() func(context.Context, string, time.Duration) *v9.BoolCmd { - f.mutex.Lock() - defer f.mutex.Unlock() - - if len(f.hooks) == 0 { - return f.defaultHook - } - - hook := f.hooks[0] - f.hooks = f.hooks[1:] - return hook -} - -func (f *RedisClientExpireNXFunc) appendCall(r0 RedisClientExpireNXFuncCall) { - f.mutex.Lock() - f.history = append(f.history, r0) - f.mutex.Unlock() -} - -// History returns a sequence of RedisClientExpireNXFuncCall objects -// describing the invocations of this function. -func (f *RedisClientExpireNXFunc) History() []RedisClientExpireNXFuncCall { - f.mutex.Lock() - history := make([]RedisClientExpireNXFuncCall, len(f.history)) - copy(history, f.history) - f.mutex.Unlock() - - return history -} - -// RedisClientExpireNXFuncCall is an object that describes an invocation of -// method ExpireNX on an instance of MockRedisClient. -type RedisClientExpireNXFuncCall struct { - // Arg0 is the value of the 1st argument passed to this method - // invocation. - Arg0 context.Context - // Arg1 is the value of the 2nd argument passed to this method - // invocation. - Arg1 string - // Arg2 is the value of the 3rd argument passed to this method - // invocation. - Arg2 time.Duration - // Result0 is the value of the 1st result returned from this method - // invocation. - Result0 *v9.BoolCmd -} - -// Args returns an interface slice containing the arguments of this -// invocation. -func (c RedisClientExpireNXFuncCall) Args() []interface{} { - return []interface{}{c.Arg0, c.Arg1, c.Arg2} -} - -// Results returns an interface slice containing the results of this -// invocation. -func (c RedisClientExpireNXFuncCall) Results() []interface{} { - return []interface{}{c.Result0} -} - -// RedisClientExpireTimeFunc describes the behavior when the ExpireTime -// method of the parent MockRedisClient instance is invoked. -type RedisClientExpireTimeFunc struct { - defaultHook func(context.Context, string) *v9.DurationCmd - hooks []func(context.Context, string) *v9.DurationCmd - history []RedisClientExpireTimeFuncCall - mutex sync.Mutex -} - -// ExpireTime delegates to the next hook function in the queue and stores -// the parameter and result values of this invocation. -func (m *MockRedisClient) ExpireTime(v0 context.Context, v1 string) *v9.DurationCmd { - r0 := m.ExpireTimeFunc.nextHook()(v0, v1) - m.ExpireTimeFunc.appendCall(RedisClientExpireTimeFuncCall{v0, v1, r0}) - return r0 -} - -// SetDefaultHook sets function that is called when the ExpireTime method of -// the parent MockRedisClient instance is invoked and the hook queue is -// empty. -func (f *RedisClientExpireTimeFunc) SetDefaultHook(hook func(context.Context, string) *v9.DurationCmd) { - f.defaultHook = hook -} - -// PushHook adds a function to the end of hook queue. Each invocation of the -// ExpireTime method of the parent MockRedisClient instance invokes the hook -// at the front of the queue and discards it. After the queue is empty, the -// default hook function is invoked for any future action. -func (f *RedisClientExpireTimeFunc) PushHook(hook func(context.Context, string) *v9.DurationCmd) { - f.mutex.Lock() - f.hooks = append(f.hooks, hook) - f.mutex.Unlock() -} - -// SetDefaultReturn calls SetDefaultHook with a function that returns the -// given values. -func (f *RedisClientExpireTimeFunc) SetDefaultReturn(r0 *v9.DurationCmd) { - f.SetDefaultHook(func(context.Context, string) *v9.DurationCmd { - return r0 - }) -} - -// PushReturn calls PushHook with a function that returns the given values. -func (f *RedisClientExpireTimeFunc) PushReturn(r0 *v9.DurationCmd) { - f.PushHook(func(context.Context, string) *v9.DurationCmd { - return r0 - }) -} - -func (f *RedisClientExpireTimeFunc) nextHook() func(context.Context, string) *v9.DurationCmd { - f.mutex.Lock() - defer f.mutex.Unlock() - - if len(f.hooks) == 0 { - return f.defaultHook - } - - hook := f.hooks[0] - f.hooks = f.hooks[1:] - return hook -} - -func (f *RedisClientExpireTimeFunc) appendCall(r0 RedisClientExpireTimeFuncCall) { - f.mutex.Lock() - f.history = append(f.history, r0) - f.mutex.Unlock() -} - -// History returns a sequence of RedisClientExpireTimeFuncCall objects -// describing the invocations of this function. -func (f *RedisClientExpireTimeFunc) History() []RedisClientExpireTimeFuncCall { - f.mutex.Lock() - history := make([]RedisClientExpireTimeFuncCall, len(f.history)) - copy(history, f.history) - f.mutex.Unlock() - - return history -} - -// RedisClientExpireTimeFuncCall is an object that describes an invocation -// of method ExpireTime on an instance of MockRedisClient. -type RedisClientExpireTimeFuncCall struct { - // Arg0 is the value of the 1st argument passed to this method - // invocation. - Arg0 context.Context - // Arg1 is the value of the 2nd argument passed to this method - // invocation. - Arg1 string - // Result0 is the value of the 1st result returned from this method - // invocation. - Result0 *v9.DurationCmd -} - -// Args returns an interface slice containing the arguments of this -// invocation. -func (c RedisClientExpireTimeFuncCall) Args() []interface{} { - return []interface{}{c.Arg0, c.Arg1} -} - -// Results returns an interface slice containing the results of this -// invocation. -func (c RedisClientExpireTimeFuncCall) Results() []interface{} { - return []interface{}{c.Result0} -} - -// RedisClientExpireXXFunc describes the behavior when the ExpireXX method -// of the parent MockRedisClient instance is invoked. -type RedisClientExpireXXFunc struct { - defaultHook func(context.Context, string, time.Duration) *v9.BoolCmd - hooks []func(context.Context, string, time.Duration) *v9.BoolCmd - history []RedisClientExpireXXFuncCall - mutex sync.Mutex -} - -// ExpireXX delegates to the next hook function in the queue and stores the -// parameter and result values of this invocation. -func (m *MockRedisClient) ExpireXX(v0 context.Context, v1 string, v2 time.Duration) *v9.BoolCmd { - r0 := m.ExpireXXFunc.nextHook()(v0, v1, v2) - m.ExpireXXFunc.appendCall(RedisClientExpireXXFuncCall{v0, v1, v2, r0}) - return r0 -} - -// SetDefaultHook sets function that is called when the ExpireXX method of -// the parent MockRedisClient instance is invoked and the hook queue is -// empty. -func (f *RedisClientExpireXXFunc) SetDefaultHook(hook func(context.Context, string, time.Duration) *v9.BoolCmd) { - f.defaultHook = hook -} - -// PushHook adds a function to the end of hook queue. Each invocation of the -// ExpireXX method of the parent MockRedisClient instance invokes the hook -// at the front of the queue and discards it. After the queue is empty, the -// default hook function is invoked for any future action. -func (f *RedisClientExpireXXFunc) PushHook(hook func(context.Context, string, time.Duration) *v9.BoolCmd) { - f.mutex.Lock() - f.hooks = append(f.hooks, hook) - f.mutex.Unlock() -} - -// SetDefaultReturn calls SetDefaultHook with a function that returns the -// given values. -func (f *RedisClientExpireXXFunc) SetDefaultReturn(r0 *v9.BoolCmd) { - f.SetDefaultHook(func(context.Context, string, time.Duration) *v9.BoolCmd { - return r0 - }) -} - -// PushReturn calls PushHook with a function that returns the given values. -func (f *RedisClientExpireXXFunc) PushReturn(r0 *v9.BoolCmd) { - f.PushHook(func(context.Context, string, time.Duration) *v9.BoolCmd { - return r0 - }) -} - -func (f *RedisClientExpireXXFunc) nextHook() func(context.Context, string, time.Duration) *v9.BoolCmd { - f.mutex.Lock() - defer f.mutex.Unlock() - - if len(f.hooks) == 0 { - return f.defaultHook - } - - hook := f.hooks[0] - f.hooks = f.hooks[1:] - return hook -} - -func (f *RedisClientExpireXXFunc) appendCall(r0 RedisClientExpireXXFuncCall) { - f.mutex.Lock() - f.history = append(f.history, r0) - f.mutex.Unlock() -} - -// History returns a sequence of RedisClientExpireXXFuncCall objects -// describing the invocations of this function. -func (f *RedisClientExpireXXFunc) History() []RedisClientExpireXXFuncCall { - f.mutex.Lock() - history := make([]RedisClientExpireXXFuncCall, len(f.history)) - copy(history, f.history) - f.mutex.Unlock() - - return history -} - -// RedisClientExpireXXFuncCall is an object that describes an invocation of -// method ExpireXX on an instance of MockRedisClient. -type RedisClientExpireXXFuncCall struct { - // Arg0 is the value of the 1st argument passed to this method - // invocation. - Arg0 context.Context - // Arg1 is the value of the 2nd argument passed to this method - // invocation. - Arg1 string - // Arg2 is the value of the 3rd argument passed to this method - // invocation. - Arg2 time.Duration - // Result0 is the value of the 1st result returned from this method - // invocation. - Result0 *v9.BoolCmd -} - -// Args returns an interface slice containing the arguments of this -// invocation. -func (c RedisClientExpireXXFuncCall) Args() []interface{} { - return []interface{}{c.Arg0, c.Arg1, c.Arg2} -} - -// Results returns an interface slice containing the results of this -// invocation. -func (c RedisClientExpireXXFuncCall) Results() []interface{} { - return []interface{}{c.Result0} -} - -// RedisClientGetFunc describes the behavior when the Get method of the -// parent MockRedisClient instance is invoked. -type RedisClientGetFunc struct { - defaultHook func(context.Context, string) *v9.StringCmd - hooks []func(context.Context, string) *v9.StringCmd - history []RedisClientGetFuncCall - mutex sync.Mutex -} - -// Get delegates to the next hook function in the queue and stores the -// parameter and result values of this invocation. -func (m *MockRedisClient) Get(v0 context.Context, v1 string) *v9.StringCmd { - r0 := m.GetFunc.nextHook()(v0, v1) - m.GetFunc.appendCall(RedisClientGetFuncCall{v0, v1, r0}) - return r0 -} - -// SetDefaultHook sets function that is called when the Get method of the -// parent MockRedisClient instance is invoked and the hook queue is empty. -func (f *RedisClientGetFunc) SetDefaultHook(hook func(context.Context, string) *v9.StringCmd) { - f.defaultHook = hook -} - -// PushHook adds a function to the end of hook queue. Each invocation of the -// Get method of the parent MockRedisClient instance invokes the hook at the -// front of the queue and discards it. After the queue is empty, the default -// hook function is invoked for any future action. -func (f *RedisClientGetFunc) PushHook(hook func(context.Context, string) *v9.StringCmd) { - f.mutex.Lock() - f.hooks = append(f.hooks, hook) - f.mutex.Unlock() -} - -// SetDefaultReturn calls SetDefaultHook with a function that returns the -// given values. -func (f *RedisClientGetFunc) SetDefaultReturn(r0 *v9.StringCmd) { - f.SetDefaultHook(func(context.Context, string) *v9.StringCmd { - return r0 - }) -} - -// PushReturn calls PushHook with a function that returns the given values. -func (f *RedisClientGetFunc) PushReturn(r0 *v9.StringCmd) { - f.PushHook(func(context.Context, string) *v9.StringCmd { - return r0 - }) -} - -func (f *RedisClientGetFunc) nextHook() func(context.Context, string) *v9.StringCmd { - f.mutex.Lock() - defer f.mutex.Unlock() - - if len(f.hooks) == 0 { - return f.defaultHook - } - - hook := f.hooks[0] - f.hooks = f.hooks[1:] - return hook -} - -func (f *RedisClientGetFunc) appendCall(r0 RedisClientGetFuncCall) { - f.mutex.Lock() - f.history = append(f.history, r0) - f.mutex.Unlock() -} - -// History returns a sequence of RedisClientGetFuncCall objects describing -// the invocations of this function. -func (f *RedisClientGetFunc) History() []RedisClientGetFuncCall { - f.mutex.Lock() - history := make([]RedisClientGetFuncCall, len(f.history)) - copy(history, f.history) - f.mutex.Unlock() - - return history -} - -// RedisClientGetFuncCall is an object that describes an invocation of -// method Get on an instance of MockRedisClient. -type RedisClientGetFuncCall struct { - // Arg0 is the value of the 1st argument passed to this method - // invocation. - Arg0 context.Context - // Arg1 is the value of the 2nd argument passed to this method - // invocation. - Arg1 string - // Result0 is the value of the 1st result returned from this method - // invocation. - Result0 *v9.StringCmd -} - -// Args returns an interface slice containing the arguments of this -// invocation. -func (c RedisClientGetFuncCall) Args() []interface{} { - return []interface{}{c.Arg0, c.Arg1} -} - -// Results returns an interface slice containing the results of this -// invocation. -func (c RedisClientGetFuncCall) Results() []interface{} { - return []interface{}{c.Result0} -} - -// RedisClientGetDelFunc describes the behavior when the GetDel method of -// the parent MockRedisClient instance is invoked. -type RedisClientGetDelFunc struct { - defaultHook func(context.Context, string) *v9.StringCmd - hooks []func(context.Context, string) *v9.StringCmd - history []RedisClientGetDelFuncCall - mutex sync.Mutex -} - -// GetDel delegates to the next hook function in the queue and stores the -// parameter and result values of this invocation. -func (m *MockRedisClient) GetDel(v0 context.Context, v1 string) *v9.StringCmd { - r0 := m.GetDelFunc.nextHook()(v0, v1) - m.GetDelFunc.appendCall(RedisClientGetDelFuncCall{v0, v1, r0}) - return r0 -} - -// SetDefaultHook sets function that is called when the GetDel method of the -// parent MockRedisClient instance is invoked and the hook queue is empty. -func (f *RedisClientGetDelFunc) SetDefaultHook(hook func(context.Context, string) *v9.StringCmd) { - f.defaultHook = hook -} - -// PushHook adds a function to the end of hook queue. Each invocation of the -// GetDel method of the parent MockRedisClient instance invokes the hook at -// the front of the queue and discards it. After the queue is empty, the -// default hook function is invoked for any future action. -func (f *RedisClientGetDelFunc) PushHook(hook func(context.Context, string) *v9.StringCmd) { - f.mutex.Lock() - f.hooks = append(f.hooks, hook) - f.mutex.Unlock() -} - -// SetDefaultReturn calls SetDefaultHook with a function that returns the -// given values. -func (f *RedisClientGetDelFunc) SetDefaultReturn(r0 *v9.StringCmd) { - f.SetDefaultHook(func(context.Context, string) *v9.StringCmd { - return r0 - }) -} - -// PushReturn calls PushHook with a function that returns the given values. -func (f *RedisClientGetDelFunc) PushReturn(r0 *v9.StringCmd) { - f.PushHook(func(context.Context, string) *v9.StringCmd { - return r0 - }) -} - -func (f *RedisClientGetDelFunc) nextHook() func(context.Context, string) *v9.StringCmd { - f.mutex.Lock() - defer f.mutex.Unlock() - - if len(f.hooks) == 0 { - return f.defaultHook - } - - hook := f.hooks[0] - f.hooks = f.hooks[1:] - return hook -} - -func (f *RedisClientGetDelFunc) appendCall(r0 RedisClientGetDelFuncCall) { - f.mutex.Lock() - f.history = append(f.history, r0) - f.mutex.Unlock() -} - -// History returns a sequence of RedisClientGetDelFuncCall objects -// describing the invocations of this function. -func (f *RedisClientGetDelFunc) History() []RedisClientGetDelFuncCall { - f.mutex.Lock() - history := make([]RedisClientGetDelFuncCall, len(f.history)) - copy(history, f.history) - f.mutex.Unlock() - - return history -} - -// RedisClientGetDelFuncCall is an object that describes an invocation of -// method GetDel on an instance of MockRedisClient. -type RedisClientGetDelFuncCall struct { - // Arg0 is the value of the 1st argument passed to this method - // invocation. - Arg0 context.Context - // Arg1 is the value of the 2nd argument passed to this method - // invocation. - Arg1 string - // Result0 is the value of the 1st result returned from this method - // invocation. - Result0 *v9.StringCmd -} - -// Args returns an interface slice containing the arguments of this -// invocation. -func (c RedisClientGetDelFuncCall) Args() []interface{} { - return []interface{}{c.Arg0, c.Arg1} -} - -// Results returns an interface slice containing the results of this -// invocation. -func (c RedisClientGetDelFuncCall) Results() []interface{} { - return []interface{}{c.Result0} -} - -// RedisClientGetExFunc describes the behavior when the GetEx method of the -// parent MockRedisClient instance is invoked. -type RedisClientGetExFunc struct { - defaultHook func(context.Context, string, time.Duration) *v9.StringCmd - hooks []func(context.Context, string, time.Duration) *v9.StringCmd - history []RedisClientGetExFuncCall - mutex sync.Mutex -} - -// GetEx delegates to the next hook function in the queue and stores the -// parameter and result values of this invocation. -func (m *MockRedisClient) GetEx(v0 context.Context, v1 string, v2 time.Duration) *v9.StringCmd { - r0 := m.GetExFunc.nextHook()(v0, v1, v2) - m.GetExFunc.appendCall(RedisClientGetExFuncCall{v0, v1, v2, r0}) - return r0 -} - -// SetDefaultHook sets function that is called when the GetEx method of the -// parent MockRedisClient instance is invoked and the hook queue is empty. -func (f *RedisClientGetExFunc) SetDefaultHook(hook func(context.Context, string, time.Duration) *v9.StringCmd) { - f.defaultHook = hook -} - -// PushHook adds a function to the end of hook queue. Each invocation of the -// GetEx method of the parent MockRedisClient instance invokes the hook at -// the front of the queue and discards it. After the queue is empty, the -// default hook function is invoked for any future action. -func (f *RedisClientGetExFunc) PushHook(hook func(context.Context, string, time.Duration) *v9.StringCmd) { - f.mutex.Lock() - f.hooks = append(f.hooks, hook) - f.mutex.Unlock() -} - -// SetDefaultReturn calls SetDefaultHook with a function that returns the -// given values. -func (f *RedisClientGetExFunc) SetDefaultReturn(r0 *v9.StringCmd) { - f.SetDefaultHook(func(context.Context, string, time.Duration) *v9.StringCmd { - return r0 - }) -} - -// PushReturn calls PushHook with a function that returns the given values. -func (f *RedisClientGetExFunc) PushReturn(r0 *v9.StringCmd) { - f.PushHook(func(context.Context, string, time.Duration) *v9.StringCmd { - return r0 - }) -} - -func (f *RedisClientGetExFunc) nextHook() func(context.Context, string, time.Duration) *v9.StringCmd { - f.mutex.Lock() - defer f.mutex.Unlock() - - if len(f.hooks) == 0 { - return f.defaultHook - } - - hook := f.hooks[0] - f.hooks = f.hooks[1:] - return hook -} - -func (f *RedisClientGetExFunc) appendCall(r0 RedisClientGetExFuncCall) { - f.mutex.Lock() - f.history = append(f.history, r0) - f.mutex.Unlock() -} - -// History returns a sequence of RedisClientGetExFuncCall objects describing -// the invocations of this function. -func (f *RedisClientGetExFunc) History() []RedisClientGetExFuncCall { - f.mutex.Lock() - history := make([]RedisClientGetExFuncCall, len(f.history)) - copy(history, f.history) - f.mutex.Unlock() - - return history -} - -// RedisClientGetExFuncCall is an object that describes an invocation of -// method GetEx on an instance of MockRedisClient. -type RedisClientGetExFuncCall struct { - // Arg0 is the value of the 1st argument passed to this method - // invocation. - Arg0 context.Context - // Arg1 is the value of the 2nd argument passed to this method - // invocation. - Arg1 string - // Arg2 is the value of the 3rd argument passed to this method - // invocation. - Arg2 time.Duration - // Result0 is the value of the 1st result returned from this method - // invocation. - Result0 *v9.StringCmd -} - -// Args returns an interface slice containing the arguments of this -// invocation. -func (c RedisClientGetExFuncCall) Args() []interface{} { - return []interface{}{c.Arg0, c.Arg1, c.Arg2} -} - -// Results returns an interface slice containing the results of this -// invocation. -func (c RedisClientGetExFuncCall) Results() []interface{} { - return []interface{}{c.Result0} -} - -// RedisClientGetRangeFunc describes the behavior when the GetRange method -// of the parent MockRedisClient instance is invoked. -type RedisClientGetRangeFunc struct { - defaultHook func(context.Context, string, int64, int64) *v9.StringCmd - hooks []func(context.Context, string, int64, int64) *v9.StringCmd - history []RedisClientGetRangeFuncCall - mutex sync.Mutex -} - -// GetRange delegates to the next hook function in the queue and stores the -// parameter and result values of this invocation. -func (m *MockRedisClient) GetRange(v0 context.Context, v1 string, v2 int64, v3 int64) *v9.StringCmd { - r0 := m.GetRangeFunc.nextHook()(v0, v1, v2, v3) - m.GetRangeFunc.appendCall(RedisClientGetRangeFuncCall{v0, v1, v2, v3, r0}) - return r0 -} - -// SetDefaultHook sets function that is called when the GetRange method of -// the parent MockRedisClient instance is invoked and the hook queue is -// empty. -func (f *RedisClientGetRangeFunc) SetDefaultHook(hook func(context.Context, string, int64, int64) *v9.StringCmd) { - f.defaultHook = hook -} - -// PushHook adds a function to the end of hook queue. Each invocation of the -// GetRange method of the parent MockRedisClient instance invokes the hook -// at the front of the queue and discards it. After the queue is empty, the -// default hook function is invoked for any future action. -func (f *RedisClientGetRangeFunc) PushHook(hook func(context.Context, string, int64, int64) *v9.StringCmd) { - f.mutex.Lock() - f.hooks = append(f.hooks, hook) - f.mutex.Unlock() -} - -// SetDefaultReturn calls SetDefaultHook with a function that returns the -// given values. -func (f *RedisClientGetRangeFunc) SetDefaultReturn(r0 *v9.StringCmd) { - f.SetDefaultHook(func(context.Context, string, int64, int64) *v9.StringCmd { - return r0 - }) -} - -// PushReturn calls PushHook with a function that returns the given values. -func (f *RedisClientGetRangeFunc) PushReturn(r0 *v9.StringCmd) { - f.PushHook(func(context.Context, string, int64, int64) *v9.StringCmd { - return r0 - }) -} - -func (f *RedisClientGetRangeFunc) nextHook() func(context.Context, string, int64, int64) *v9.StringCmd { - f.mutex.Lock() - defer f.mutex.Unlock() - - if len(f.hooks) == 0 { - return f.defaultHook - } - - hook := f.hooks[0] - f.hooks = f.hooks[1:] - return hook -} - -func (f *RedisClientGetRangeFunc) appendCall(r0 RedisClientGetRangeFuncCall) { - f.mutex.Lock() - f.history = append(f.history, r0) - f.mutex.Unlock() -} - -// History returns a sequence of RedisClientGetRangeFuncCall objects -// describing the invocations of this function. -func (f *RedisClientGetRangeFunc) History() []RedisClientGetRangeFuncCall { - f.mutex.Lock() - history := make([]RedisClientGetRangeFuncCall, len(f.history)) - copy(history, f.history) - f.mutex.Unlock() - - return history -} - -// RedisClientGetRangeFuncCall is an object that describes an invocation of -// method GetRange on an instance of MockRedisClient. -type RedisClientGetRangeFuncCall struct { - // Arg0 is the value of the 1st argument passed to this method - // invocation. - Arg0 context.Context - // Arg1 is the value of the 2nd argument passed to this method - // invocation. - Arg1 string - // Arg2 is the value of the 3rd argument passed to this method - // invocation. - Arg2 int64 - // Arg3 is the value of the 4th argument passed to this method - // invocation. - Arg3 int64 - // Result0 is the value of the 1st result returned from this method - // invocation. - Result0 *v9.StringCmd -} - -// Args returns an interface slice containing the arguments of this -// invocation. -func (c RedisClientGetRangeFuncCall) Args() []interface{} { - return []interface{}{c.Arg0, c.Arg1, c.Arg2, c.Arg3} -} - -// Results returns an interface slice containing the results of this -// invocation. -func (c RedisClientGetRangeFuncCall) Results() []interface{} { - return []interface{}{c.Result0} -} - -// RedisClientGetSetFunc describes the behavior when the GetSet method of -// the parent MockRedisClient instance is invoked. -type RedisClientGetSetFunc struct { - defaultHook func(context.Context, string, interface{}) *v9.StringCmd - hooks []func(context.Context, string, interface{}) *v9.StringCmd - history []RedisClientGetSetFuncCall - mutex sync.Mutex -} - -// GetSet delegates to the next hook function in the queue and stores the -// parameter and result values of this invocation. -func (m *MockRedisClient) GetSet(v0 context.Context, v1 string, v2 interface{}) *v9.StringCmd { - r0 := m.GetSetFunc.nextHook()(v0, v1, v2) - m.GetSetFunc.appendCall(RedisClientGetSetFuncCall{v0, v1, v2, r0}) - return r0 -} - -// SetDefaultHook sets function that is called when the GetSet method of the -// parent MockRedisClient instance is invoked and the hook queue is empty. -func (f *RedisClientGetSetFunc) SetDefaultHook(hook func(context.Context, string, interface{}) *v9.StringCmd) { - f.defaultHook = hook -} - -// PushHook adds a function to the end of hook queue. Each invocation of the -// GetSet method of the parent MockRedisClient instance invokes the hook at -// the front of the queue and discards it. After the queue is empty, the -// default hook function is invoked for any future action. -func (f *RedisClientGetSetFunc) PushHook(hook func(context.Context, string, interface{}) *v9.StringCmd) { - f.mutex.Lock() - f.hooks = append(f.hooks, hook) - f.mutex.Unlock() -} - -// SetDefaultReturn calls SetDefaultHook with a function that returns the -// given values. -func (f *RedisClientGetSetFunc) SetDefaultReturn(r0 *v9.StringCmd) { - f.SetDefaultHook(func(context.Context, string, interface{}) *v9.StringCmd { - return r0 - }) -} - -// PushReturn calls PushHook with a function that returns the given values. -func (f *RedisClientGetSetFunc) PushReturn(r0 *v9.StringCmd) { - f.PushHook(func(context.Context, string, interface{}) *v9.StringCmd { - return r0 - }) -} - -func (f *RedisClientGetSetFunc) nextHook() func(context.Context, string, interface{}) *v9.StringCmd { - f.mutex.Lock() - defer f.mutex.Unlock() - - if len(f.hooks) == 0 { - return f.defaultHook - } - - hook := f.hooks[0] - f.hooks = f.hooks[1:] - return hook -} - -func (f *RedisClientGetSetFunc) appendCall(r0 RedisClientGetSetFuncCall) { - f.mutex.Lock() - f.history = append(f.history, r0) - f.mutex.Unlock() -} - -// History returns a sequence of RedisClientGetSetFuncCall objects -// describing the invocations of this function. -func (f *RedisClientGetSetFunc) History() []RedisClientGetSetFuncCall { - f.mutex.Lock() - history := make([]RedisClientGetSetFuncCall, len(f.history)) - copy(history, f.history) - f.mutex.Unlock() - - return history -} - -// RedisClientGetSetFuncCall is an object that describes an invocation of -// method GetSet on an instance of MockRedisClient. -type RedisClientGetSetFuncCall struct { - // Arg0 is the value of the 1st argument passed to this method - // invocation. - Arg0 context.Context - // Arg1 is the value of the 2nd argument passed to this method - // invocation. - Arg1 string - // Arg2 is the value of the 3rd argument passed to this method - // invocation. - Arg2 interface{} - // Result0 is the value of the 1st result returned from this method - // invocation. - Result0 *v9.StringCmd -} - -// Args returns an interface slice containing the arguments of this -// invocation. -func (c RedisClientGetSetFuncCall) Args() []interface{} { - return []interface{}{c.Arg0, c.Arg1, c.Arg2} -} - -// Results returns an interface slice containing the results of this -// invocation. -func (c RedisClientGetSetFuncCall) Results() []interface{} { - return []interface{}{c.Result0} -} - -// RedisClientIncrFunc describes the behavior when the Incr method of the -// parent MockRedisClient instance is invoked. -type RedisClientIncrFunc struct { - defaultHook func(context.Context, string) *v9.IntCmd - hooks []func(context.Context, string) *v9.IntCmd - history []RedisClientIncrFuncCall - mutex sync.Mutex -} - -// Incr delegates to the next hook function in the queue and stores the -// parameter and result values of this invocation. -func (m *MockRedisClient) Incr(v0 context.Context, v1 string) *v9.IntCmd { - r0 := m.IncrFunc.nextHook()(v0, v1) - m.IncrFunc.appendCall(RedisClientIncrFuncCall{v0, v1, r0}) - return r0 -} - -// SetDefaultHook sets function that is called when the Incr method of the -// parent MockRedisClient instance is invoked and the hook queue is empty. -func (f *RedisClientIncrFunc) SetDefaultHook(hook func(context.Context, string) *v9.IntCmd) { - f.defaultHook = hook -} - -// PushHook adds a function to the end of hook queue. Each invocation of the -// Incr method of the parent MockRedisClient instance invokes the hook at -// the front of the queue and discards it. After the queue is empty, the -// default hook function is invoked for any future action. -func (f *RedisClientIncrFunc) PushHook(hook func(context.Context, string) *v9.IntCmd) { - f.mutex.Lock() - f.hooks = append(f.hooks, hook) - f.mutex.Unlock() -} - -// SetDefaultReturn calls SetDefaultHook with a function that returns the -// given values. -func (f *RedisClientIncrFunc) SetDefaultReturn(r0 *v9.IntCmd) { - f.SetDefaultHook(func(context.Context, string) *v9.IntCmd { - return r0 - }) -} - -// PushReturn calls PushHook with a function that returns the given values. -func (f *RedisClientIncrFunc) PushReturn(r0 *v9.IntCmd) { - f.PushHook(func(context.Context, string) *v9.IntCmd { - return r0 - }) -} - -func (f *RedisClientIncrFunc) nextHook() func(context.Context, string) *v9.IntCmd { - f.mutex.Lock() - defer f.mutex.Unlock() - - if len(f.hooks) == 0 { - return f.defaultHook - } - - hook := f.hooks[0] - f.hooks = f.hooks[1:] - return hook -} - -func (f *RedisClientIncrFunc) appendCall(r0 RedisClientIncrFuncCall) { - f.mutex.Lock() - f.history = append(f.history, r0) - f.mutex.Unlock() -} - -// History returns a sequence of RedisClientIncrFuncCall objects describing -// the invocations of this function. -func (f *RedisClientIncrFunc) History() []RedisClientIncrFuncCall { - f.mutex.Lock() - history := make([]RedisClientIncrFuncCall, len(f.history)) - copy(history, f.history) - f.mutex.Unlock() - - return history -} - -// RedisClientIncrFuncCall is an object that describes an invocation of -// method Incr on an instance of MockRedisClient. -type RedisClientIncrFuncCall struct { - // Arg0 is the value of the 1st argument passed to this method - // invocation. - Arg0 context.Context - // Arg1 is the value of the 2nd argument passed to this method - // invocation. - Arg1 string - // Result0 is the value of the 1st result returned from this method - // invocation. - Result0 *v9.IntCmd -} - -// Args returns an interface slice containing the arguments of this -// invocation. -func (c RedisClientIncrFuncCall) Args() []interface{} { - return []interface{}{c.Arg0, c.Arg1} -} - -// Results returns an interface slice containing the results of this -// invocation. -func (c RedisClientIncrFuncCall) Results() []interface{} { - return []interface{}{c.Result0} -} - -// RedisClientIncrByFunc describes the behavior when the IncrBy method of -// the parent MockRedisClient instance is invoked. -type RedisClientIncrByFunc struct { - defaultHook func(context.Context, string, int64) *v9.IntCmd - hooks []func(context.Context, string, int64) *v9.IntCmd - history []RedisClientIncrByFuncCall - mutex sync.Mutex -} - -// IncrBy delegates to the next hook function in the queue and stores the -// parameter and result values of this invocation. -func (m *MockRedisClient) IncrBy(v0 context.Context, v1 string, v2 int64) *v9.IntCmd { - r0 := m.IncrByFunc.nextHook()(v0, v1, v2) - m.IncrByFunc.appendCall(RedisClientIncrByFuncCall{v0, v1, v2, r0}) - return r0 -} - -// SetDefaultHook sets function that is called when the IncrBy method of the -// parent MockRedisClient instance is invoked and the hook queue is empty. -func (f *RedisClientIncrByFunc) SetDefaultHook(hook func(context.Context, string, int64) *v9.IntCmd) { - f.defaultHook = hook -} - -// PushHook adds a function to the end of hook queue. Each invocation of the -// IncrBy method of the parent MockRedisClient instance invokes the hook at -// the front of the queue and discards it. After the queue is empty, the -// default hook function is invoked for any future action. -func (f *RedisClientIncrByFunc) PushHook(hook func(context.Context, string, int64) *v9.IntCmd) { - f.mutex.Lock() - f.hooks = append(f.hooks, hook) - f.mutex.Unlock() -} - -// SetDefaultReturn calls SetDefaultHook with a function that returns the -// given values. -func (f *RedisClientIncrByFunc) SetDefaultReturn(r0 *v9.IntCmd) { - f.SetDefaultHook(func(context.Context, string, int64) *v9.IntCmd { - return r0 - }) -} - -// PushReturn calls PushHook with a function that returns the given values. -func (f *RedisClientIncrByFunc) PushReturn(r0 *v9.IntCmd) { - f.PushHook(func(context.Context, string, int64) *v9.IntCmd { - return r0 - }) -} - -func (f *RedisClientIncrByFunc) nextHook() func(context.Context, string, int64) *v9.IntCmd { - f.mutex.Lock() - defer f.mutex.Unlock() - - if len(f.hooks) == 0 { - return f.defaultHook - } - - hook := f.hooks[0] - f.hooks = f.hooks[1:] - return hook -} - -func (f *RedisClientIncrByFunc) appendCall(r0 RedisClientIncrByFuncCall) { - f.mutex.Lock() - f.history = append(f.history, r0) - f.mutex.Unlock() -} - -// History returns a sequence of RedisClientIncrByFuncCall objects -// describing the invocations of this function. -func (f *RedisClientIncrByFunc) History() []RedisClientIncrByFuncCall { - f.mutex.Lock() - history := make([]RedisClientIncrByFuncCall, len(f.history)) - copy(history, f.history) - f.mutex.Unlock() - - return history -} - -// RedisClientIncrByFuncCall is an object that describes an invocation of -// method IncrBy on an instance of MockRedisClient. -type RedisClientIncrByFuncCall struct { - // Arg0 is the value of the 1st argument passed to this method - // invocation. - Arg0 context.Context - // Arg1 is the value of the 2nd argument passed to this method - // invocation. - Arg1 string - // Arg2 is the value of the 3rd argument passed to this method - // invocation. - Arg2 int64 - // Result0 is the value of the 1st result returned from this method - // invocation. - Result0 *v9.IntCmd -} - -// Args returns an interface slice containing the arguments of this -// invocation. -func (c RedisClientIncrByFuncCall) Args() []interface{} { - return []interface{}{c.Arg0, c.Arg1, c.Arg2} -} - -// Results returns an interface slice containing the results of this -// invocation. -func (c RedisClientIncrByFuncCall) Results() []interface{} { - return []interface{}{c.Result0} -} - -// RedisClientIncrByFloatFunc describes the behavior when the IncrByFloat -// method of the parent MockRedisClient instance is invoked. -type RedisClientIncrByFloatFunc struct { - defaultHook func(context.Context, string, float64) *v9.FloatCmd - hooks []func(context.Context, string, float64) *v9.FloatCmd - history []RedisClientIncrByFloatFuncCall - mutex sync.Mutex -} - -// IncrByFloat delegates to the next hook function in the queue and stores -// the parameter and result values of this invocation. -func (m *MockRedisClient) IncrByFloat(v0 context.Context, v1 string, v2 float64) *v9.FloatCmd { - r0 := m.IncrByFloatFunc.nextHook()(v0, v1, v2) - m.IncrByFloatFunc.appendCall(RedisClientIncrByFloatFuncCall{v0, v1, v2, r0}) - return r0 -} - -// SetDefaultHook sets function that is called when the IncrByFloat method -// of the parent MockRedisClient instance is invoked and the hook queue is -// empty. -func (f *RedisClientIncrByFloatFunc) SetDefaultHook(hook func(context.Context, string, float64) *v9.FloatCmd) { - f.defaultHook = hook -} - -// PushHook adds a function to the end of hook queue. Each invocation of the -// IncrByFloat method of the parent MockRedisClient instance invokes the -// hook at the front of the queue and discards it. After the queue is empty, -// the default hook function is invoked for any future action. -func (f *RedisClientIncrByFloatFunc) PushHook(hook func(context.Context, string, float64) *v9.FloatCmd) { - f.mutex.Lock() - f.hooks = append(f.hooks, hook) - f.mutex.Unlock() -} - -// SetDefaultReturn calls SetDefaultHook with a function that returns the -// given values. -func (f *RedisClientIncrByFloatFunc) SetDefaultReturn(r0 *v9.FloatCmd) { - f.SetDefaultHook(func(context.Context, string, float64) *v9.FloatCmd { - return r0 - }) -} - -// PushReturn calls PushHook with a function that returns the given values. -func (f *RedisClientIncrByFloatFunc) PushReturn(r0 *v9.FloatCmd) { - f.PushHook(func(context.Context, string, float64) *v9.FloatCmd { - return r0 - }) -} - -func (f *RedisClientIncrByFloatFunc) nextHook() func(context.Context, string, float64) *v9.FloatCmd { - f.mutex.Lock() - defer f.mutex.Unlock() - - if len(f.hooks) == 0 { - return f.defaultHook - } - - hook := f.hooks[0] - f.hooks = f.hooks[1:] - return hook -} - -func (f *RedisClientIncrByFloatFunc) appendCall(r0 RedisClientIncrByFloatFuncCall) { - f.mutex.Lock() - f.history = append(f.history, r0) - f.mutex.Unlock() -} - -// History returns a sequence of RedisClientIncrByFloatFuncCall objects -// describing the invocations of this function. -func (f *RedisClientIncrByFloatFunc) History() []RedisClientIncrByFloatFuncCall { - f.mutex.Lock() - history := make([]RedisClientIncrByFloatFuncCall, len(f.history)) - copy(history, f.history) - f.mutex.Unlock() - - return history -} - -// RedisClientIncrByFloatFuncCall is an object that describes an invocation -// of method IncrByFloat on an instance of MockRedisClient. -type RedisClientIncrByFloatFuncCall struct { - // Arg0 is the value of the 1st argument passed to this method - // invocation. - Arg0 context.Context - // Arg1 is the value of the 2nd argument passed to this method - // invocation. - Arg1 string - // Arg2 is the value of the 3rd argument passed to this method - // invocation. - Arg2 float64 - // Result0 is the value of the 1st result returned from this method - // invocation. - Result0 *v9.FloatCmd -} - -// Args returns an interface slice containing the arguments of this -// invocation. -func (c RedisClientIncrByFloatFuncCall) Args() []interface{} { - return []interface{}{c.Arg0, c.Arg1, c.Arg2} -} - -// Results returns an interface slice containing the results of this -// invocation. -func (c RedisClientIncrByFloatFuncCall) Results() []interface{} { - return []interface{}{c.Result0} -} - -// RedisClientKeysFunc describes the behavior when the Keys method of the -// parent MockRedisClient instance is invoked. -type RedisClientKeysFunc struct { - defaultHook func(context.Context, string) *v9.StringSliceCmd - hooks []func(context.Context, string) *v9.StringSliceCmd - history []RedisClientKeysFuncCall - mutex sync.Mutex -} - -// Keys delegates to the next hook function in the queue and stores the -// parameter and result values of this invocation. -func (m *MockRedisClient) Keys(v0 context.Context, v1 string) *v9.StringSliceCmd { - r0 := m.KeysFunc.nextHook()(v0, v1) - m.KeysFunc.appendCall(RedisClientKeysFuncCall{v0, v1, r0}) - return r0 -} - -// SetDefaultHook sets function that is called when the Keys method of the -// parent MockRedisClient instance is invoked and the hook queue is empty. -func (f *RedisClientKeysFunc) SetDefaultHook(hook func(context.Context, string) *v9.StringSliceCmd) { - f.defaultHook = hook -} - -// PushHook adds a function to the end of hook queue. Each invocation of the -// Keys method of the parent MockRedisClient instance invokes the hook at -// the front of the queue and discards it. After the queue is empty, the -// default hook function is invoked for any future action. -func (f *RedisClientKeysFunc) PushHook(hook func(context.Context, string) *v9.StringSliceCmd) { - f.mutex.Lock() - f.hooks = append(f.hooks, hook) - f.mutex.Unlock() -} - -// SetDefaultReturn calls SetDefaultHook with a function that returns the -// given values. -func (f *RedisClientKeysFunc) SetDefaultReturn(r0 *v9.StringSliceCmd) { - f.SetDefaultHook(func(context.Context, string) *v9.StringSliceCmd { - return r0 - }) -} - -// PushReturn calls PushHook with a function that returns the given values. -func (f *RedisClientKeysFunc) PushReturn(r0 *v9.StringSliceCmd) { - f.PushHook(func(context.Context, string) *v9.StringSliceCmd { - return r0 - }) -} - -func (f *RedisClientKeysFunc) nextHook() func(context.Context, string) *v9.StringSliceCmd { - f.mutex.Lock() - defer f.mutex.Unlock() - - if len(f.hooks) == 0 { - return f.defaultHook - } - - hook := f.hooks[0] - f.hooks = f.hooks[1:] - return hook -} - -func (f *RedisClientKeysFunc) appendCall(r0 RedisClientKeysFuncCall) { - f.mutex.Lock() - f.history = append(f.history, r0) - f.mutex.Unlock() -} - -// History returns a sequence of RedisClientKeysFuncCall objects describing -// the invocations of this function. -func (f *RedisClientKeysFunc) History() []RedisClientKeysFuncCall { - f.mutex.Lock() - history := make([]RedisClientKeysFuncCall, len(f.history)) - copy(history, f.history) - f.mutex.Unlock() - - return history -} - -// RedisClientKeysFuncCall is an object that describes an invocation of -// method Keys on an instance of MockRedisClient. -type RedisClientKeysFuncCall struct { - // Arg0 is the value of the 1st argument passed to this method - // invocation. - Arg0 context.Context - // Arg1 is the value of the 2nd argument passed to this method - // invocation. - Arg1 string - // Result0 is the value of the 1st result returned from this method - // invocation. - Result0 *v9.StringSliceCmd -} - -// Args returns an interface slice containing the arguments of this -// invocation. -func (c RedisClientKeysFuncCall) Args() []interface{} { - return []interface{}{c.Arg0, c.Arg1} -} - -// Results returns an interface slice containing the results of this -// invocation. -func (c RedisClientKeysFuncCall) Results() []interface{} { - return []interface{}{c.Result0} -} - -// RedisClientLCSFunc describes the behavior when the LCS method of the -// parent MockRedisClient instance is invoked. -type RedisClientLCSFunc struct { - defaultHook func(context.Context, *v9.LCSQuery) *v9.LCSCmd - hooks []func(context.Context, *v9.LCSQuery) *v9.LCSCmd - history []RedisClientLCSFuncCall - mutex sync.Mutex -} - -// LCS delegates to the next hook function in the queue and stores the -// parameter and result values of this invocation. -func (m *MockRedisClient) LCS(v0 context.Context, v1 *v9.LCSQuery) *v9.LCSCmd { - r0 := m.LCSFunc.nextHook()(v0, v1) - m.LCSFunc.appendCall(RedisClientLCSFuncCall{v0, v1, r0}) - return r0 -} - -// SetDefaultHook sets function that is called when the LCS method of the -// parent MockRedisClient instance is invoked and the hook queue is empty. -func (f *RedisClientLCSFunc) SetDefaultHook(hook func(context.Context, *v9.LCSQuery) *v9.LCSCmd) { - f.defaultHook = hook -} - -// PushHook adds a function to the end of hook queue. Each invocation of the -// LCS method of the parent MockRedisClient instance invokes the hook at the -// front of the queue and discards it. After the queue is empty, the default -// hook function is invoked for any future action. -func (f *RedisClientLCSFunc) PushHook(hook func(context.Context, *v9.LCSQuery) *v9.LCSCmd) { - f.mutex.Lock() - f.hooks = append(f.hooks, hook) - f.mutex.Unlock() -} - -// SetDefaultReturn calls SetDefaultHook with a function that returns the -// given values. -func (f *RedisClientLCSFunc) SetDefaultReturn(r0 *v9.LCSCmd) { - f.SetDefaultHook(func(context.Context, *v9.LCSQuery) *v9.LCSCmd { - return r0 - }) -} - -// PushReturn calls PushHook with a function that returns the given values. -func (f *RedisClientLCSFunc) PushReturn(r0 *v9.LCSCmd) { - f.PushHook(func(context.Context, *v9.LCSQuery) *v9.LCSCmd { - return r0 - }) -} - -func (f *RedisClientLCSFunc) nextHook() func(context.Context, *v9.LCSQuery) *v9.LCSCmd { - f.mutex.Lock() - defer f.mutex.Unlock() - - if len(f.hooks) == 0 { - return f.defaultHook - } - - hook := f.hooks[0] - f.hooks = f.hooks[1:] - return hook -} - -func (f *RedisClientLCSFunc) appendCall(r0 RedisClientLCSFuncCall) { - f.mutex.Lock() - f.history = append(f.history, r0) - f.mutex.Unlock() -} - -// History returns a sequence of RedisClientLCSFuncCall objects describing -// the invocations of this function. -func (f *RedisClientLCSFunc) History() []RedisClientLCSFuncCall { - f.mutex.Lock() - history := make([]RedisClientLCSFuncCall, len(f.history)) - copy(history, f.history) - f.mutex.Unlock() - - return history -} - -// RedisClientLCSFuncCall is an object that describes an invocation of -// method LCS on an instance of MockRedisClient. -type RedisClientLCSFuncCall struct { - // Arg0 is the value of the 1st argument passed to this method - // invocation. - Arg0 context.Context - // Arg1 is the value of the 2nd argument passed to this method - // invocation. - Arg1 *v9.LCSQuery - // Result0 is the value of the 1st result returned from this method - // invocation. - Result0 *v9.LCSCmd -} - -// Args returns an interface slice containing the arguments of this -// invocation. -func (c RedisClientLCSFuncCall) Args() []interface{} { - return []interface{}{c.Arg0, c.Arg1} -} - -// Results returns an interface slice containing the results of this -// invocation. -func (c RedisClientLCSFuncCall) Results() []interface{} { - return []interface{}{c.Result0} -} - -// RedisClientMGetFunc describes the behavior when the MGet method of the -// parent MockRedisClient instance is invoked. -type RedisClientMGetFunc struct { - defaultHook func(context.Context, ...string) *v9.SliceCmd - hooks []func(context.Context, ...string) *v9.SliceCmd - history []RedisClientMGetFuncCall - mutex sync.Mutex -} - -// MGet delegates to the next hook function in the queue and stores the -// parameter and result values of this invocation. -func (m *MockRedisClient) MGet(v0 context.Context, v1 ...string) *v9.SliceCmd { - r0 := m.MGetFunc.nextHook()(v0, v1...) - m.MGetFunc.appendCall(RedisClientMGetFuncCall{v0, v1, r0}) - return r0 -} - -// SetDefaultHook sets function that is called when the MGet method of the -// parent MockRedisClient instance is invoked and the hook queue is empty. -func (f *RedisClientMGetFunc) SetDefaultHook(hook func(context.Context, ...string) *v9.SliceCmd) { - f.defaultHook = hook -} - -// PushHook adds a function to the end of hook queue. Each invocation of the -// MGet method of the parent MockRedisClient instance invokes the hook at -// the front of the queue and discards it. After the queue is empty, the -// default hook function is invoked for any future action. -func (f *RedisClientMGetFunc) PushHook(hook func(context.Context, ...string) *v9.SliceCmd) { - f.mutex.Lock() - f.hooks = append(f.hooks, hook) - f.mutex.Unlock() -} - -// SetDefaultReturn calls SetDefaultHook with a function that returns the -// given values. -func (f *RedisClientMGetFunc) SetDefaultReturn(r0 *v9.SliceCmd) { - f.SetDefaultHook(func(context.Context, ...string) *v9.SliceCmd { - return r0 - }) -} - -// PushReturn calls PushHook with a function that returns the given values. -func (f *RedisClientMGetFunc) PushReturn(r0 *v9.SliceCmd) { - f.PushHook(func(context.Context, ...string) *v9.SliceCmd { - return r0 - }) -} - -func (f *RedisClientMGetFunc) nextHook() func(context.Context, ...string) *v9.SliceCmd { - f.mutex.Lock() - defer f.mutex.Unlock() - - if len(f.hooks) == 0 { - return f.defaultHook - } - - hook := f.hooks[0] - f.hooks = f.hooks[1:] - return hook -} - -func (f *RedisClientMGetFunc) appendCall(r0 RedisClientMGetFuncCall) { - f.mutex.Lock() - f.history = append(f.history, r0) - f.mutex.Unlock() -} - -// History returns a sequence of RedisClientMGetFuncCall objects describing -// the invocations of this function. -func (f *RedisClientMGetFunc) History() []RedisClientMGetFuncCall { - f.mutex.Lock() - history := make([]RedisClientMGetFuncCall, len(f.history)) - copy(history, f.history) - f.mutex.Unlock() - - return history -} - -// RedisClientMGetFuncCall is an object that describes an invocation of -// method MGet on an instance of MockRedisClient. -type RedisClientMGetFuncCall struct { - // Arg0 is the value of the 1st argument passed to this method - // invocation. - Arg0 context.Context - // Arg1 is a slice containing the values of the variadic arguments - // passed to this method invocation. - Arg1 []string - // Result0 is the value of the 1st result returned from this method - // invocation. - Result0 *v9.SliceCmd -} - -// Args returns an interface slice containing the arguments of this -// invocation. The variadic slice argument is flattened in this array such -// that one positional argument and three variadic arguments would result in -// a slice of four, not two. -func (c RedisClientMGetFuncCall) Args() []interface{} { - trailing := []interface{}{} - for _, val := range c.Arg1 { - trailing = append(trailing, val) - } - - return append([]interface{}{c.Arg0}, trailing...) -} - -// Results returns an interface slice containing the results of this -// invocation. -func (c RedisClientMGetFuncCall) Results() []interface{} { - return []interface{}{c.Result0} -} - -// RedisClientMSetFunc describes the behavior when the MSet method of the -// parent MockRedisClient instance is invoked. -type RedisClientMSetFunc struct { - defaultHook func(context.Context, ...interface{}) *v9.StatusCmd - hooks []func(context.Context, ...interface{}) *v9.StatusCmd - history []RedisClientMSetFuncCall - mutex sync.Mutex -} - -// MSet delegates to the next hook function in the queue and stores the -// parameter and result values of this invocation. -func (m *MockRedisClient) MSet(v0 context.Context, v1 ...interface{}) *v9.StatusCmd { - r0 := m.MSetFunc.nextHook()(v0, v1...) - m.MSetFunc.appendCall(RedisClientMSetFuncCall{v0, v1, r0}) - return r0 -} - -// SetDefaultHook sets function that is called when the MSet method of the -// parent MockRedisClient instance is invoked and the hook queue is empty. -func (f *RedisClientMSetFunc) SetDefaultHook(hook func(context.Context, ...interface{}) *v9.StatusCmd) { - f.defaultHook = hook -} - -// PushHook adds a function to the end of hook queue. Each invocation of the -// MSet method of the parent MockRedisClient instance invokes the hook at -// the front of the queue and discards it. After the queue is empty, the -// default hook function is invoked for any future action. -func (f *RedisClientMSetFunc) PushHook(hook func(context.Context, ...interface{}) *v9.StatusCmd) { - f.mutex.Lock() - f.hooks = append(f.hooks, hook) - f.mutex.Unlock() -} - -// SetDefaultReturn calls SetDefaultHook with a function that returns the -// given values. -func (f *RedisClientMSetFunc) SetDefaultReturn(r0 *v9.StatusCmd) { - f.SetDefaultHook(func(context.Context, ...interface{}) *v9.StatusCmd { - return r0 - }) -} - -// PushReturn calls PushHook with a function that returns the given values. -func (f *RedisClientMSetFunc) PushReturn(r0 *v9.StatusCmd) { - f.PushHook(func(context.Context, ...interface{}) *v9.StatusCmd { - return r0 - }) -} - -func (f *RedisClientMSetFunc) nextHook() func(context.Context, ...interface{}) *v9.StatusCmd { - f.mutex.Lock() - defer f.mutex.Unlock() - - if len(f.hooks) == 0 { - return f.defaultHook - } - - hook := f.hooks[0] - f.hooks = f.hooks[1:] - return hook -} - -func (f *RedisClientMSetFunc) appendCall(r0 RedisClientMSetFuncCall) { - f.mutex.Lock() - f.history = append(f.history, r0) - f.mutex.Unlock() -} - -// History returns a sequence of RedisClientMSetFuncCall objects describing -// the invocations of this function. -func (f *RedisClientMSetFunc) History() []RedisClientMSetFuncCall { - f.mutex.Lock() - history := make([]RedisClientMSetFuncCall, len(f.history)) - copy(history, f.history) - f.mutex.Unlock() - - return history -} - -// RedisClientMSetFuncCall is an object that describes an invocation of -// method MSet on an instance of MockRedisClient. -type RedisClientMSetFuncCall struct { - // Arg0 is the value of the 1st argument passed to this method - // invocation. - Arg0 context.Context - // Arg1 is a slice containing the values of the variadic arguments - // passed to this method invocation. - Arg1 []interface{} - // Result0 is the value of the 1st result returned from this method - // invocation. - Result0 *v9.StatusCmd -} - -// Args returns an interface slice containing the arguments of this -// invocation. The variadic slice argument is flattened in this array such -// that one positional argument and three variadic arguments would result in -// a slice of four, not two. -func (c RedisClientMSetFuncCall) Args() []interface{} { - trailing := []interface{}{} - for _, val := range c.Arg1 { - trailing = append(trailing, val) - } - - return append([]interface{}{c.Arg0}, trailing...) -} - -// Results returns an interface slice containing the results of this -// invocation. -func (c RedisClientMSetFuncCall) Results() []interface{} { - return []interface{}{c.Result0} -} - -// RedisClientMSetNXFunc describes the behavior when the MSetNX method of -// the parent MockRedisClient instance is invoked. -type RedisClientMSetNXFunc struct { - defaultHook func(context.Context, ...interface{}) *v9.BoolCmd - hooks []func(context.Context, ...interface{}) *v9.BoolCmd - history []RedisClientMSetNXFuncCall - mutex sync.Mutex -} - -// MSetNX delegates to the next hook function in the queue and stores the -// parameter and result values of this invocation. -func (m *MockRedisClient) MSetNX(v0 context.Context, v1 ...interface{}) *v9.BoolCmd { - r0 := m.MSetNXFunc.nextHook()(v0, v1...) - m.MSetNXFunc.appendCall(RedisClientMSetNXFuncCall{v0, v1, r0}) - return r0 -} - -// SetDefaultHook sets function that is called when the MSetNX method of the -// parent MockRedisClient instance is invoked and the hook queue is empty. -func (f *RedisClientMSetNXFunc) SetDefaultHook(hook func(context.Context, ...interface{}) *v9.BoolCmd) { - f.defaultHook = hook -} - -// PushHook adds a function to the end of hook queue. Each invocation of the -// MSetNX method of the parent MockRedisClient instance invokes the hook at -// the front of the queue and discards it. After the queue is empty, the -// default hook function is invoked for any future action. -func (f *RedisClientMSetNXFunc) PushHook(hook func(context.Context, ...interface{}) *v9.BoolCmd) { - f.mutex.Lock() - f.hooks = append(f.hooks, hook) - f.mutex.Unlock() -} - -// SetDefaultReturn calls SetDefaultHook with a function that returns the -// given values. -func (f *RedisClientMSetNXFunc) SetDefaultReturn(r0 *v9.BoolCmd) { - f.SetDefaultHook(func(context.Context, ...interface{}) *v9.BoolCmd { - return r0 - }) -} - -// PushReturn calls PushHook with a function that returns the given values. -func (f *RedisClientMSetNXFunc) PushReturn(r0 *v9.BoolCmd) { - f.PushHook(func(context.Context, ...interface{}) *v9.BoolCmd { - return r0 - }) -} - -func (f *RedisClientMSetNXFunc) nextHook() func(context.Context, ...interface{}) *v9.BoolCmd { - f.mutex.Lock() - defer f.mutex.Unlock() - - if len(f.hooks) == 0 { - return f.defaultHook - } - - hook := f.hooks[0] - f.hooks = f.hooks[1:] - return hook -} - -func (f *RedisClientMSetNXFunc) appendCall(r0 RedisClientMSetNXFuncCall) { - f.mutex.Lock() - f.history = append(f.history, r0) - f.mutex.Unlock() -} - -// History returns a sequence of RedisClientMSetNXFuncCall objects -// describing the invocations of this function. -func (f *RedisClientMSetNXFunc) History() []RedisClientMSetNXFuncCall { - f.mutex.Lock() - history := make([]RedisClientMSetNXFuncCall, len(f.history)) - copy(history, f.history) - f.mutex.Unlock() - - return history -} - -// RedisClientMSetNXFuncCall is an object that describes an invocation of -// method MSetNX on an instance of MockRedisClient. -type RedisClientMSetNXFuncCall struct { - // Arg0 is the value of the 1st argument passed to this method - // invocation. - Arg0 context.Context - // Arg1 is a slice containing the values of the variadic arguments - // passed to this method invocation. - Arg1 []interface{} - // Result0 is the value of the 1st result returned from this method - // invocation. - Result0 *v9.BoolCmd -} - -// Args returns an interface slice containing the arguments of this -// invocation. The variadic slice argument is flattened in this array such -// that one positional argument and three variadic arguments would result in -// a slice of four, not two. -func (c RedisClientMSetNXFuncCall) Args() []interface{} { - trailing := []interface{}{} - for _, val := range c.Arg1 { - trailing = append(trailing, val) - } - - return append([]interface{}{c.Arg0}, trailing...) -} - -// Results returns an interface slice containing the results of this -// invocation. -func (c RedisClientMSetNXFuncCall) Results() []interface{} { - return []interface{}{c.Result0} -} - -// RedisClientMigrateFunc describes the behavior when the Migrate method of -// the parent MockRedisClient instance is invoked. -type RedisClientMigrateFunc struct { - defaultHook func(context.Context, string, string, string, int, time.Duration) *v9.StatusCmd - hooks []func(context.Context, string, string, string, int, time.Duration) *v9.StatusCmd - history []RedisClientMigrateFuncCall - mutex sync.Mutex -} - -// Migrate delegates to the next hook function in the queue and stores the -// parameter and result values of this invocation. -func (m *MockRedisClient) Migrate(v0 context.Context, v1 string, v2 string, v3 string, v4 int, v5 time.Duration) *v9.StatusCmd { - r0 := m.MigrateFunc.nextHook()(v0, v1, v2, v3, v4, v5) - m.MigrateFunc.appendCall(RedisClientMigrateFuncCall{v0, v1, v2, v3, v4, v5, r0}) - return r0 -} - -// SetDefaultHook sets function that is called when the Migrate method of -// the parent MockRedisClient instance is invoked and the hook queue is -// empty. -func (f *RedisClientMigrateFunc) SetDefaultHook(hook func(context.Context, string, string, string, int, time.Duration) *v9.StatusCmd) { - f.defaultHook = hook -} - -// PushHook adds a function to the end of hook queue. Each invocation of the -// Migrate method of the parent MockRedisClient instance invokes the hook at -// the front of the queue and discards it. After the queue is empty, the -// default hook function is invoked for any future action. -func (f *RedisClientMigrateFunc) PushHook(hook func(context.Context, string, string, string, int, time.Duration) *v9.StatusCmd) { - f.mutex.Lock() - f.hooks = append(f.hooks, hook) - f.mutex.Unlock() -} - -// SetDefaultReturn calls SetDefaultHook with a function that returns the -// given values. -func (f *RedisClientMigrateFunc) SetDefaultReturn(r0 *v9.StatusCmd) { - f.SetDefaultHook(func(context.Context, string, string, string, int, time.Duration) *v9.StatusCmd { - return r0 - }) -} - -// PushReturn calls PushHook with a function that returns the given values. -func (f *RedisClientMigrateFunc) PushReturn(r0 *v9.StatusCmd) { - f.PushHook(func(context.Context, string, string, string, int, time.Duration) *v9.StatusCmd { - return r0 - }) -} - -func (f *RedisClientMigrateFunc) nextHook() func(context.Context, string, string, string, int, time.Duration) *v9.StatusCmd { - f.mutex.Lock() - defer f.mutex.Unlock() - - if len(f.hooks) == 0 { - return f.defaultHook - } - - hook := f.hooks[0] - f.hooks = f.hooks[1:] - return hook -} - -func (f *RedisClientMigrateFunc) appendCall(r0 RedisClientMigrateFuncCall) { - f.mutex.Lock() - f.history = append(f.history, r0) - f.mutex.Unlock() -} - -// History returns a sequence of RedisClientMigrateFuncCall objects -// describing the invocations of this function. -func (f *RedisClientMigrateFunc) History() []RedisClientMigrateFuncCall { - f.mutex.Lock() - history := make([]RedisClientMigrateFuncCall, len(f.history)) - copy(history, f.history) - f.mutex.Unlock() - - return history -} - -// RedisClientMigrateFuncCall is an object that describes an invocation of -// method Migrate on an instance of MockRedisClient. -type RedisClientMigrateFuncCall struct { - // Arg0 is the value of the 1st argument passed to this method - // invocation. - Arg0 context.Context - // Arg1 is the value of the 2nd argument passed to this method - // invocation. - Arg1 string - // Arg2 is the value of the 3rd argument passed to this method - // invocation. - Arg2 string - // Arg3 is the value of the 4th argument passed to this method - // invocation. - Arg3 string - // Arg4 is the value of the 5th argument passed to this method - // invocation. - Arg4 int - // Arg5 is the value of the 6th argument passed to this method - // invocation. - Arg5 time.Duration - // Result0 is the value of the 1st result returned from this method - // invocation. - Result0 *v9.StatusCmd -} - -// Args returns an interface slice containing the arguments of this -// invocation. -func (c RedisClientMigrateFuncCall) Args() []interface{} { - return []interface{}{c.Arg0, c.Arg1, c.Arg2, c.Arg3, c.Arg4, c.Arg5} -} - -// Results returns an interface slice containing the results of this -// invocation. -func (c RedisClientMigrateFuncCall) Results() []interface{} { - return []interface{}{c.Result0} -} - -// RedisClientMoveFunc describes the behavior when the Move method of the -// parent MockRedisClient instance is invoked. -type RedisClientMoveFunc struct { - defaultHook func(context.Context, string, int) *v9.BoolCmd - hooks []func(context.Context, string, int) *v9.BoolCmd - history []RedisClientMoveFuncCall - mutex sync.Mutex -} - -// Move delegates to the next hook function in the queue and stores the -// parameter and result values of this invocation. -func (m *MockRedisClient) Move(v0 context.Context, v1 string, v2 int) *v9.BoolCmd { - r0 := m.MoveFunc.nextHook()(v0, v1, v2) - m.MoveFunc.appendCall(RedisClientMoveFuncCall{v0, v1, v2, r0}) - return r0 -} - -// SetDefaultHook sets function that is called when the Move method of the -// parent MockRedisClient instance is invoked and the hook queue is empty. -func (f *RedisClientMoveFunc) SetDefaultHook(hook func(context.Context, string, int) *v9.BoolCmd) { - f.defaultHook = hook -} - -// PushHook adds a function to the end of hook queue. Each invocation of the -// Move method of the parent MockRedisClient instance invokes the hook at -// the front of the queue and discards it. After the queue is empty, the -// default hook function is invoked for any future action. -func (f *RedisClientMoveFunc) PushHook(hook func(context.Context, string, int) *v9.BoolCmd) { - f.mutex.Lock() - f.hooks = append(f.hooks, hook) - f.mutex.Unlock() -} - -// SetDefaultReturn calls SetDefaultHook with a function that returns the -// given values. -func (f *RedisClientMoveFunc) SetDefaultReturn(r0 *v9.BoolCmd) { - f.SetDefaultHook(func(context.Context, string, int) *v9.BoolCmd { - return r0 - }) -} - -// PushReturn calls PushHook with a function that returns the given values. -func (f *RedisClientMoveFunc) PushReturn(r0 *v9.BoolCmd) { - f.PushHook(func(context.Context, string, int) *v9.BoolCmd { - return r0 - }) -} - -func (f *RedisClientMoveFunc) nextHook() func(context.Context, string, int) *v9.BoolCmd { - f.mutex.Lock() - defer f.mutex.Unlock() - - if len(f.hooks) == 0 { - return f.defaultHook - } - - hook := f.hooks[0] - f.hooks = f.hooks[1:] - return hook -} - -func (f *RedisClientMoveFunc) appendCall(r0 RedisClientMoveFuncCall) { - f.mutex.Lock() - f.history = append(f.history, r0) - f.mutex.Unlock() -} - -// History returns a sequence of RedisClientMoveFuncCall objects describing -// the invocations of this function. -func (f *RedisClientMoveFunc) History() []RedisClientMoveFuncCall { - f.mutex.Lock() - history := make([]RedisClientMoveFuncCall, len(f.history)) - copy(history, f.history) - f.mutex.Unlock() - - return history -} - -// RedisClientMoveFuncCall is an object that describes an invocation of -// method Move on an instance of MockRedisClient. -type RedisClientMoveFuncCall struct { - // Arg0 is the value of the 1st argument passed to this method - // invocation. - Arg0 context.Context - // Arg1 is the value of the 2nd argument passed to this method - // invocation. - Arg1 string - // Arg2 is the value of the 3rd argument passed to this method - // invocation. - Arg2 int - // Result0 is the value of the 1st result returned from this method - // invocation. - Result0 *v9.BoolCmd -} - -// Args returns an interface slice containing the arguments of this -// invocation. -func (c RedisClientMoveFuncCall) Args() []interface{} { - return []interface{}{c.Arg0, c.Arg1, c.Arg2} -} - -// Results returns an interface slice containing the results of this -// invocation. -func (c RedisClientMoveFuncCall) Results() []interface{} { - return []interface{}{c.Result0} -} - -// RedisClientObjectEncodingFunc describes the behavior when the -// ObjectEncoding method of the parent MockRedisClient instance is invoked. -type RedisClientObjectEncodingFunc struct { - defaultHook func(context.Context, string) *v9.StringCmd - hooks []func(context.Context, string) *v9.StringCmd - history []RedisClientObjectEncodingFuncCall - mutex sync.Mutex -} - -// ObjectEncoding delegates to the next hook function in the queue and -// stores the parameter and result values of this invocation. -func (m *MockRedisClient) ObjectEncoding(v0 context.Context, v1 string) *v9.StringCmd { - r0 := m.ObjectEncodingFunc.nextHook()(v0, v1) - m.ObjectEncodingFunc.appendCall(RedisClientObjectEncodingFuncCall{v0, v1, r0}) - return r0 -} - -// SetDefaultHook sets function that is called when the ObjectEncoding -// method of the parent MockRedisClient instance is invoked and the hook -// queue is empty. -func (f *RedisClientObjectEncodingFunc) SetDefaultHook(hook func(context.Context, string) *v9.StringCmd) { - f.defaultHook = hook -} - -// PushHook adds a function to the end of hook queue. Each invocation of the -// ObjectEncoding method of the parent MockRedisClient instance invokes the -// hook at the front of the queue and discards it. After the queue is empty, -// the default hook function is invoked for any future action. -func (f *RedisClientObjectEncodingFunc) PushHook(hook func(context.Context, string) *v9.StringCmd) { - f.mutex.Lock() - f.hooks = append(f.hooks, hook) - f.mutex.Unlock() -} - -// SetDefaultReturn calls SetDefaultHook with a function that returns the -// given values. -func (f *RedisClientObjectEncodingFunc) SetDefaultReturn(r0 *v9.StringCmd) { - f.SetDefaultHook(func(context.Context, string) *v9.StringCmd { - return r0 - }) -} - -// PushReturn calls PushHook with a function that returns the given values. -func (f *RedisClientObjectEncodingFunc) PushReturn(r0 *v9.StringCmd) { - f.PushHook(func(context.Context, string) *v9.StringCmd { - return r0 - }) -} - -func (f *RedisClientObjectEncodingFunc) nextHook() func(context.Context, string) *v9.StringCmd { - f.mutex.Lock() - defer f.mutex.Unlock() - - if len(f.hooks) == 0 { - return f.defaultHook - } - - hook := f.hooks[0] - f.hooks = f.hooks[1:] - return hook -} - -func (f *RedisClientObjectEncodingFunc) appendCall(r0 RedisClientObjectEncodingFuncCall) { - f.mutex.Lock() - f.history = append(f.history, r0) - f.mutex.Unlock() -} - -// History returns a sequence of RedisClientObjectEncodingFuncCall objects -// describing the invocations of this function. -func (f *RedisClientObjectEncodingFunc) History() []RedisClientObjectEncodingFuncCall { - f.mutex.Lock() - history := make([]RedisClientObjectEncodingFuncCall, len(f.history)) - copy(history, f.history) - f.mutex.Unlock() - - return history -} - -// RedisClientObjectEncodingFuncCall is an object that describes an -// invocation of method ObjectEncoding on an instance of MockRedisClient. -type RedisClientObjectEncodingFuncCall struct { - // Arg0 is the value of the 1st argument passed to this method - // invocation. - Arg0 context.Context - // Arg1 is the value of the 2nd argument passed to this method - // invocation. - Arg1 string - // Result0 is the value of the 1st result returned from this method - // invocation. - Result0 *v9.StringCmd -} - -// Args returns an interface slice containing the arguments of this -// invocation. -func (c RedisClientObjectEncodingFuncCall) Args() []interface{} { - return []interface{}{c.Arg0, c.Arg1} -} - -// Results returns an interface slice containing the results of this -// invocation. -func (c RedisClientObjectEncodingFuncCall) Results() []interface{} { - return []interface{}{c.Result0} -} - -// RedisClientObjectFreqFunc describes the behavior when the ObjectFreq -// method of the parent MockRedisClient instance is invoked. -type RedisClientObjectFreqFunc struct { - defaultHook func(context.Context, string) *v9.IntCmd - hooks []func(context.Context, string) *v9.IntCmd - history []RedisClientObjectFreqFuncCall - mutex sync.Mutex -} - -// ObjectFreq delegates to the next hook function in the queue and stores -// the parameter and result values of this invocation. -func (m *MockRedisClient) ObjectFreq(v0 context.Context, v1 string) *v9.IntCmd { - r0 := m.ObjectFreqFunc.nextHook()(v0, v1) - m.ObjectFreqFunc.appendCall(RedisClientObjectFreqFuncCall{v0, v1, r0}) - return r0 -} - -// SetDefaultHook sets function that is called when the ObjectFreq method of -// the parent MockRedisClient instance is invoked and the hook queue is -// empty. -func (f *RedisClientObjectFreqFunc) SetDefaultHook(hook func(context.Context, string) *v9.IntCmd) { - f.defaultHook = hook -} - -// PushHook adds a function to the end of hook queue. Each invocation of the -// ObjectFreq method of the parent MockRedisClient instance invokes the hook -// at the front of the queue and discards it. After the queue is empty, the -// default hook function is invoked for any future action. -func (f *RedisClientObjectFreqFunc) PushHook(hook func(context.Context, string) *v9.IntCmd) { - f.mutex.Lock() - f.hooks = append(f.hooks, hook) - f.mutex.Unlock() -} - -// SetDefaultReturn calls SetDefaultHook with a function that returns the -// given values. -func (f *RedisClientObjectFreqFunc) SetDefaultReturn(r0 *v9.IntCmd) { - f.SetDefaultHook(func(context.Context, string) *v9.IntCmd { - return r0 - }) -} - -// PushReturn calls PushHook with a function that returns the given values. -func (f *RedisClientObjectFreqFunc) PushReturn(r0 *v9.IntCmd) { - f.PushHook(func(context.Context, string) *v9.IntCmd { - return r0 - }) -} - -func (f *RedisClientObjectFreqFunc) nextHook() func(context.Context, string) *v9.IntCmd { - f.mutex.Lock() - defer f.mutex.Unlock() - - if len(f.hooks) == 0 { - return f.defaultHook - } - - hook := f.hooks[0] - f.hooks = f.hooks[1:] - return hook -} - -func (f *RedisClientObjectFreqFunc) appendCall(r0 RedisClientObjectFreqFuncCall) { - f.mutex.Lock() - f.history = append(f.history, r0) - f.mutex.Unlock() -} - -// History returns a sequence of RedisClientObjectFreqFuncCall objects -// describing the invocations of this function. -func (f *RedisClientObjectFreqFunc) History() []RedisClientObjectFreqFuncCall { - f.mutex.Lock() - history := make([]RedisClientObjectFreqFuncCall, len(f.history)) - copy(history, f.history) - f.mutex.Unlock() - - return history -} - -// RedisClientObjectFreqFuncCall is an object that describes an invocation -// of method ObjectFreq on an instance of MockRedisClient. -type RedisClientObjectFreqFuncCall struct { - // Arg0 is the value of the 1st argument passed to this method - // invocation. - Arg0 context.Context - // Arg1 is the value of the 2nd argument passed to this method - // invocation. - Arg1 string - // Result0 is the value of the 1st result returned from this method - // invocation. - Result0 *v9.IntCmd -} - -// Args returns an interface slice containing the arguments of this -// invocation. -func (c RedisClientObjectFreqFuncCall) Args() []interface{} { - return []interface{}{c.Arg0, c.Arg1} -} - -// Results returns an interface slice containing the results of this -// invocation. -func (c RedisClientObjectFreqFuncCall) Results() []interface{} { - return []interface{}{c.Result0} -} - -// RedisClientObjectIdleTimeFunc describes the behavior when the -// ObjectIdleTime method of the parent MockRedisClient instance is invoked. -type RedisClientObjectIdleTimeFunc struct { - defaultHook func(context.Context, string) *v9.DurationCmd - hooks []func(context.Context, string) *v9.DurationCmd - history []RedisClientObjectIdleTimeFuncCall - mutex sync.Mutex -} - -// ObjectIdleTime delegates to the next hook function in the queue and -// stores the parameter and result values of this invocation. -func (m *MockRedisClient) ObjectIdleTime(v0 context.Context, v1 string) *v9.DurationCmd { - r0 := m.ObjectIdleTimeFunc.nextHook()(v0, v1) - m.ObjectIdleTimeFunc.appendCall(RedisClientObjectIdleTimeFuncCall{v0, v1, r0}) - return r0 -} - -// SetDefaultHook sets function that is called when the ObjectIdleTime -// method of the parent MockRedisClient instance is invoked and the hook -// queue is empty. -func (f *RedisClientObjectIdleTimeFunc) SetDefaultHook(hook func(context.Context, string) *v9.DurationCmd) { - f.defaultHook = hook -} - -// PushHook adds a function to the end of hook queue. Each invocation of the -// ObjectIdleTime method of the parent MockRedisClient instance invokes the -// hook at the front of the queue and discards it. After the queue is empty, -// the default hook function is invoked for any future action. -func (f *RedisClientObjectIdleTimeFunc) PushHook(hook func(context.Context, string) *v9.DurationCmd) { - f.mutex.Lock() - f.hooks = append(f.hooks, hook) - f.mutex.Unlock() -} - -// SetDefaultReturn calls SetDefaultHook with a function that returns the -// given values. -func (f *RedisClientObjectIdleTimeFunc) SetDefaultReturn(r0 *v9.DurationCmd) { - f.SetDefaultHook(func(context.Context, string) *v9.DurationCmd { - return r0 - }) -} - -// PushReturn calls PushHook with a function that returns the given values. -func (f *RedisClientObjectIdleTimeFunc) PushReturn(r0 *v9.DurationCmd) { - f.PushHook(func(context.Context, string) *v9.DurationCmd { - return r0 - }) -} - -func (f *RedisClientObjectIdleTimeFunc) nextHook() func(context.Context, string) *v9.DurationCmd { - f.mutex.Lock() - defer f.mutex.Unlock() - - if len(f.hooks) == 0 { - return f.defaultHook - } - - hook := f.hooks[0] - f.hooks = f.hooks[1:] - return hook -} - -func (f *RedisClientObjectIdleTimeFunc) appendCall(r0 RedisClientObjectIdleTimeFuncCall) { - f.mutex.Lock() - f.history = append(f.history, r0) - f.mutex.Unlock() -} - -// History returns a sequence of RedisClientObjectIdleTimeFuncCall objects -// describing the invocations of this function. -func (f *RedisClientObjectIdleTimeFunc) History() []RedisClientObjectIdleTimeFuncCall { - f.mutex.Lock() - history := make([]RedisClientObjectIdleTimeFuncCall, len(f.history)) - copy(history, f.history) - f.mutex.Unlock() - - return history -} - -// RedisClientObjectIdleTimeFuncCall is an object that describes an -// invocation of method ObjectIdleTime on an instance of MockRedisClient. -type RedisClientObjectIdleTimeFuncCall struct { - // Arg0 is the value of the 1st argument passed to this method - // invocation. - Arg0 context.Context - // Arg1 is the value of the 2nd argument passed to this method - // invocation. - Arg1 string - // Result0 is the value of the 1st result returned from this method - // invocation. - Result0 *v9.DurationCmd -} - -// Args returns an interface slice containing the arguments of this -// invocation. -func (c RedisClientObjectIdleTimeFuncCall) Args() []interface{} { - return []interface{}{c.Arg0, c.Arg1} -} - -// Results returns an interface slice containing the results of this -// invocation. -func (c RedisClientObjectIdleTimeFuncCall) Results() []interface{} { - return []interface{}{c.Result0} -} - -// RedisClientObjectRefCountFunc describes the behavior when the -// ObjectRefCount method of the parent MockRedisClient instance is invoked. -type RedisClientObjectRefCountFunc struct { - defaultHook func(context.Context, string) *v9.IntCmd - hooks []func(context.Context, string) *v9.IntCmd - history []RedisClientObjectRefCountFuncCall - mutex sync.Mutex -} - -// ObjectRefCount delegates to the next hook function in the queue and -// stores the parameter and result values of this invocation. -func (m *MockRedisClient) ObjectRefCount(v0 context.Context, v1 string) *v9.IntCmd { - r0 := m.ObjectRefCountFunc.nextHook()(v0, v1) - m.ObjectRefCountFunc.appendCall(RedisClientObjectRefCountFuncCall{v0, v1, r0}) - return r0 -} - -// SetDefaultHook sets function that is called when the ObjectRefCount -// method of the parent MockRedisClient instance is invoked and the hook -// queue is empty. -func (f *RedisClientObjectRefCountFunc) SetDefaultHook(hook func(context.Context, string) *v9.IntCmd) { - f.defaultHook = hook -} - -// PushHook adds a function to the end of hook queue. Each invocation of the -// ObjectRefCount method of the parent MockRedisClient instance invokes the -// hook at the front of the queue and discards it. After the queue is empty, -// the default hook function is invoked for any future action. -func (f *RedisClientObjectRefCountFunc) PushHook(hook func(context.Context, string) *v9.IntCmd) { - f.mutex.Lock() - f.hooks = append(f.hooks, hook) - f.mutex.Unlock() -} - -// SetDefaultReturn calls SetDefaultHook with a function that returns the -// given values. -func (f *RedisClientObjectRefCountFunc) SetDefaultReturn(r0 *v9.IntCmd) { - f.SetDefaultHook(func(context.Context, string) *v9.IntCmd { - return r0 - }) -} - -// PushReturn calls PushHook with a function that returns the given values. -func (f *RedisClientObjectRefCountFunc) PushReturn(r0 *v9.IntCmd) { - f.PushHook(func(context.Context, string) *v9.IntCmd { - return r0 - }) -} - -func (f *RedisClientObjectRefCountFunc) nextHook() func(context.Context, string) *v9.IntCmd { - f.mutex.Lock() - defer f.mutex.Unlock() - - if len(f.hooks) == 0 { - return f.defaultHook - } - - hook := f.hooks[0] - f.hooks = f.hooks[1:] - return hook -} - -func (f *RedisClientObjectRefCountFunc) appendCall(r0 RedisClientObjectRefCountFuncCall) { - f.mutex.Lock() - f.history = append(f.history, r0) - f.mutex.Unlock() -} - -// History returns a sequence of RedisClientObjectRefCountFuncCall objects -// describing the invocations of this function. -func (f *RedisClientObjectRefCountFunc) History() []RedisClientObjectRefCountFuncCall { - f.mutex.Lock() - history := make([]RedisClientObjectRefCountFuncCall, len(f.history)) - copy(history, f.history) - f.mutex.Unlock() - - return history -} - -// RedisClientObjectRefCountFuncCall is an object that describes an -// invocation of method ObjectRefCount on an instance of MockRedisClient. -type RedisClientObjectRefCountFuncCall struct { - // Arg0 is the value of the 1st argument passed to this method - // invocation. - Arg0 context.Context - // Arg1 is the value of the 2nd argument passed to this method - // invocation. - Arg1 string - // Result0 is the value of the 1st result returned from this method - // invocation. - Result0 *v9.IntCmd -} - -// Args returns an interface slice containing the arguments of this -// invocation. -func (c RedisClientObjectRefCountFuncCall) Args() []interface{} { - return []interface{}{c.Arg0, c.Arg1} -} - -// Results returns an interface slice containing the results of this -// invocation. -func (c RedisClientObjectRefCountFuncCall) Results() []interface{} { - return []interface{}{c.Result0} -} - -// RedisClientPExpireFunc describes the behavior when the PExpire method of -// the parent MockRedisClient instance is invoked. -type RedisClientPExpireFunc struct { - defaultHook func(context.Context, string, time.Duration) *v9.BoolCmd - hooks []func(context.Context, string, time.Duration) *v9.BoolCmd - history []RedisClientPExpireFuncCall - mutex sync.Mutex -} - -// PExpire delegates to the next hook function in the queue and stores the -// parameter and result values of this invocation. -func (m *MockRedisClient) PExpire(v0 context.Context, v1 string, v2 time.Duration) *v9.BoolCmd { - r0 := m.PExpireFunc.nextHook()(v0, v1, v2) - m.PExpireFunc.appendCall(RedisClientPExpireFuncCall{v0, v1, v2, r0}) - return r0 -} - -// SetDefaultHook sets function that is called when the PExpire method of -// the parent MockRedisClient instance is invoked and the hook queue is -// empty. -func (f *RedisClientPExpireFunc) SetDefaultHook(hook func(context.Context, string, time.Duration) *v9.BoolCmd) { - f.defaultHook = hook -} - -// PushHook adds a function to the end of hook queue. Each invocation of the -// PExpire method of the parent MockRedisClient instance invokes the hook at -// the front of the queue and discards it. After the queue is empty, the -// default hook function is invoked for any future action. -func (f *RedisClientPExpireFunc) PushHook(hook func(context.Context, string, time.Duration) *v9.BoolCmd) { - f.mutex.Lock() - f.hooks = append(f.hooks, hook) - f.mutex.Unlock() -} - -// SetDefaultReturn calls SetDefaultHook with a function that returns the -// given values. -func (f *RedisClientPExpireFunc) SetDefaultReturn(r0 *v9.BoolCmd) { - f.SetDefaultHook(func(context.Context, string, time.Duration) *v9.BoolCmd { - return r0 - }) -} - -// PushReturn calls PushHook with a function that returns the given values. -func (f *RedisClientPExpireFunc) PushReturn(r0 *v9.BoolCmd) { - f.PushHook(func(context.Context, string, time.Duration) *v9.BoolCmd { - return r0 - }) -} - -func (f *RedisClientPExpireFunc) nextHook() func(context.Context, string, time.Duration) *v9.BoolCmd { - f.mutex.Lock() - defer f.mutex.Unlock() - - if len(f.hooks) == 0 { - return f.defaultHook - } - - hook := f.hooks[0] - f.hooks = f.hooks[1:] - return hook -} - -func (f *RedisClientPExpireFunc) appendCall(r0 RedisClientPExpireFuncCall) { - f.mutex.Lock() - f.history = append(f.history, r0) - f.mutex.Unlock() -} - -// History returns a sequence of RedisClientPExpireFuncCall objects -// describing the invocations of this function. -func (f *RedisClientPExpireFunc) History() []RedisClientPExpireFuncCall { - f.mutex.Lock() - history := make([]RedisClientPExpireFuncCall, len(f.history)) - copy(history, f.history) - f.mutex.Unlock() - - return history -} - -// RedisClientPExpireFuncCall is an object that describes an invocation of -// method PExpire on an instance of MockRedisClient. -type RedisClientPExpireFuncCall struct { - // Arg0 is the value of the 1st argument passed to this method - // invocation. - Arg0 context.Context - // Arg1 is the value of the 2nd argument passed to this method - // invocation. - Arg1 string - // Arg2 is the value of the 3rd argument passed to this method - // invocation. - Arg2 time.Duration - // Result0 is the value of the 1st result returned from this method - // invocation. - Result0 *v9.BoolCmd -} - -// Args returns an interface slice containing the arguments of this -// invocation. -func (c RedisClientPExpireFuncCall) Args() []interface{} { - return []interface{}{c.Arg0, c.Arg1, c.Arg2} -} - -// Results returns an interface slice containing the results of this -// invocation. -func (c RedisClientPExpireFuncCall) Results() []interface{} { - return []interface{}{c.Result0} -} - -// RedisClientPExpireAtFunc describes the behavior when the PExpireAt method -// of the parent MockRedisClient instance is invoked. -type RedisClientPExpireAtFunc struct { - defaultHook func(context.Context, string, time.Time) *v9.BoolCmd - hooks []func(context.Context, string, time.Time) *v9.BoolCmd - history []RedisClientPExpireAtFuncCall - mutex sync.Mutex -} - -// PExpireAt delegates to the next hook function in the queue and stores the -// parameter and result values of this invocation. -func (m *MockRedisClient) PExpireAt(v0 context.Context, v1 string, v2 time.Time) *v9.BoolCmd { - r0 := m.PExpireAtFunc.nextHook()(v0, v1, v2) - m.PExpireAtFunc.appendCall(RedisClientPExpireAtFuncCall{v0, v1, v2, r0}) - return r0 -} - -// SetDefaultHook sets function that is called when the PExpireAt method of -// the parent MockRedisClient instance is invoked and the hook queue is -// empty. -func (f *RedisClientPExpireAtFunc) SetDefaultHook(hook func(context.Context, string, time.Time) *v9.BoolCmd) { - f.defaultHook = hook -} - -// PushHook adds a function to the end of hook queue. Each invocation of the -// PExpireAt method of the parent MockRedisClient instance invokes the hook -// at the front of the queue and discards it. After the queue is empty, the -// default hook function is invoked for any future action. -func (f *RedisClientPExpireAtFunc) PushHook(hook func(context.Context, string, time.Time) *v9.BoolCmd) { - f.mutex.Lock() - f.hooks = append(f.hooks, hook) - f.mutex.Unlock() -} - -// SetDefaultReturn calls SetDefaultHook with a function that returns the -// given values. -func (f *RedisClientPExpireAtFunc) SetDefaultReturn(r0 *v9.BoolCmd) { - f.SetDefaultHook(func(context.Context, string, time.Time) *v9.BoolCmd { - return r0 - }) -} - -// PushReturn calls PushHook with a function that returns the given values. -func (f *RedisClientPExpireAtFunc) PushReturn(r0 *v9.BoolCmd) { - f.PushHook(func(context.Context, string, time.Time) *v9.BoolCmd { - return r0 - }) -} - -func (f *RedisClientPExpireAtFunc) nextHook() func(context.Context, string, time.Time) *v9.BoolCmd { - f.mutex.Lock() - defer f.mutex.Unlock() - - if len(f.hooks) == 0 { - return f.defaultHook - } - - hook := f.hooks[0] - f.hooks = f.hooks[1:] - return hook -} - -func (f *RedisClientPExpireAtFunc) appendCall(r0 RedisClientPExpireAtFuncCall) { - f.mutex.Lock() - f.history = append(f.history, r0) - f.mutex.Unlock() -} - -// History returns a sequence of RedisClientPExpireAtFuncCall objects -// describing the invocations of this function. -func (f *RedisClientPExpireAtFunc) History() []RedisClientPExpireAtFuncCall { - f.mutex.Lock() - history := make([]RedisClientPExpireAtFuncCall, len(f.history)) - copy(history, f.history) - f.mutex.Unlock() - - return history -} - -// RedisClientPExpireAtFuncCall is an object that describes an invocation of -// method PExpireAt on an instance of MockRedisClient. -type RedisClientPExpireAtFuncCall struct { - // Arg0 is the value of the 1st argument passed to this method - // invocation. - Arg0 context.Context - // Arg1 is the value of the 2nd argument passed to this method - // invocation. - Arg1 string - // Arg2 is the value of the 3rd argument passed to this method - // invocation. - Arg2 time.Time - // Result0 is the value of the 1st result returned from this method - // invocation. - Result0 *v9.BoolCmd -} - -// Args returns an interface slice containing the arguments of this -// invocation. -func (c RedisClientPExpireAtFuncCall) Args() []interface{} { - return []interface{}{c.Arg0, c.Arg1, c.Arg2} -} - -// Results returns an interface slice containing the results of this -// invocation. -func (c RedisClientPExpireAtFuncCall) Results() []interface{} { - return []interface{}{c.Result0} -} - -// RedisClientPExpireTimeFunc describes the behavior when the PExpireTime -// method of the parent MockRedisClient instance is invoked. -type RedisClientPExpireTimeFunc struct { - defaultHook func(context.Context, string) *v9.DurationCmd - hooks []func(context.Context, string) *v9.DurationCmd - history []RedisClientPExpireTimeFuncCall - mutex sync.Mutex -} - -// PExpireTime delegates to the next hook function in the queue and stores -// the parameter and result values of this invocation. -func (m *MockRedisClient) PExpireTime(v0 context.Context, v1 string) *v9.DurationCmd { - r0 := m.PExpireTimeFunc.nextHook()(v0, v1) - m.PExpireTimeFunc.appendCall(RedisClientPExpireTimeFuncCall{v0, v1, r0}) - return r0 -} - -// SetDefaultHook sets function that is called when the PExpireTime method -// of the parent MockRedisClient instance is invoked and the hook queue is -// empty. -func (f *RedisClientPExpireTimeFunc) SetDefaultHook(hook func(context.Context, string) *v9.DurationCmd) { - f.defaultHook = hook -} - -// PushHook adds a function to the end of hook queue. Each invocation of the -// PExpireTime method of the parent MockRedisClient instance invokes the -// hook at the front of the queue and discards it. After the queue is empty, -// the default hook function is invoked for any future action. -func (f *RedisClientPExpireTimeFunc) PushHook(hook func(context.Context, string) *v9.DurationCmd) { - f.mutex.Lock() - f.hooks = append(f.hooks, hook) - f.mutex.Unlock() -} - -// SetDefaultReturn calls SetDefaultHook with a function that returns the -// given values. -func (f *RedisClientPExpireTimeFunc) SetDefaultReturn(r0 *v9.DurationCmd) { - f.SetDefaultHook(func(context.Context, string) *v9.DurationCmd { - return r0 - }) -} - -// PushReturn calls PushHook with a function that returns the given values. -func (f *RedisClientPExpireTimeFunc) PushReturn(r0 *v9.DurationCmd) { - f.PushHook(func(context.Context, string) *v9.DurationCmd { - return r0 - }) -} - -func (f *RedisClientPExpireTimeFunc) nextHook() func(context.Context, string) *v9.DurationCmd { - f.mutex.Lock() - defer f.mutex.Unlock() - - if len(f.hooks) == 0 { - return f.defaultHook - } - - hook := f.hooks[0] - f.hooks = f.hooks[1:] - return hook -} - -func (f *RedisClientPExpireTimeFunc) appendCall(r0 RedisClientPExpireTimeFuncCall) { - f.mutex.Lock() - f.history = append(f.history, r0) - f.mutex.Unlock() -} - -// History returns a sequence of RedisClientPExpireTimeFuncCall objects -// describing the invocations of this function. -func (f *RedisClientPExpireTimeFunc) History() []RedisClientPExpireTimeFuncCall { - f.mutex.Lock() - history := make([]RedisClientPExpireTimeFuncCall, len(f.history)) - copy(history, f.history) - f.mutex.Unlock() - - return history -} - -// RedisClientPExpireTimeFuncCall is an object that describes an invocation -// of method PExpireTime on an instance of MockRedisClient. -type RedisClientPExpireTimeFuncCall struct { - // Arg0 is the value of the 1st argument passed to this method - // invocation. - Arg0 context.Context - // Arg1 is the value of the 2nd argument passed to this method - // invocation. - Arg1 string - // Result0 is the value of the 1st result returned from this method - // invocation. - Result0 *v9.DurationCmd -} - -// Args returns an interface slice containing the arguments of this -// invocation. -func (c RedisClientPExpireTimeFuncCall) Args() []interface{} { - return []interface{}{c.Arg0, c.Arg1} -} - -// Results returns an interface slice containing the results of this -// invocation. -func (c RedisClientPExpireTimeFuncCall) Results() []interface{} { - return []interface{}{c.Result0} -} - -// RedisClientPTTLFunc describes the behavior when the PTTL method of the -// parent MockRedisClient instance is invoked. -type RedisClientPTTLFunc struct { - defaultHook func(context.Context, string) *v9.DurationCmd - hooks []func(context.Context, string) *v9.DurationCmd - history []RedisClientPTTLFuncCall - mutex sync.Mutex -} - -// PTTL delegates to the next hook function in the queue and stores the -// parameter and result values of this invocation. -func (m *MockRedisClient) PTTL(v0 context.Context, v1 string) *v9.DurationCmd { - r0 := m.PTTLFunc.nextHook()(v0, v1) - m.PTTLFunc.appendCall(RedisClientPTTLFuncCall{v0, v1, r0}) - return r0 -} - -// SetDefaultHook sets function that is called when the PTTL method of the -// parent MockRedisClient instance is invoked and the hook queue is empty. -func (f *RedisClientPTTLFunc) SetDefaultHook(hook func(context.Context, string) *v9.DurationCmd) { - f.defaultHook = hook -} - -// PushHook adds a function to the end of hook queue. Each invocation of the -// PTTL method of the parent MockRedisClient instance invokes the hook at -// the front of the queue and discards it. After the queue is empty, the -// default hook function is invoked for any future action. -func (f *RedisClientPTTLFunc) PushHook(hook func(context.Context, string) *v9.DurationCmd) { - f.mutex.Lock() - f.hooks = append(f.hooks, hook) - f.mutex.Unlock() -} - -// SetDefaultReturn calls SetDefaultHook with a function that returns the -// given values. -func (f *RedisClientPTTLFunc) SetDefaultReturn(r0 *v9.DurationCmd) { - f.SetDefaultHook(func(context.Context, string) *v9.DurationCmd { - return r0 - }) -} - -// PushReturn calls PushHook with a function that returns the given values. -func (f *RedisClientPTTLFunc) PushReturn(r0 *v9.DurationCmd) { - f.PushHook(func(context.Context, string) *v9.DurationCmd { - return r0 - }) -} - -func (f *RedisClientPTTLFunc) nextHook() func(context.Context, string) *v9.DurationCmd { - f.mutex.Lock() - defer f.mutex.Unlock() - - if len(f.hooks) == 0 { - return f.defaultHook - } - - hook := f.hooks[0] - f.hooks = f.hooks[1:] - return hook -} - -func (f *RedisClientPTTLFunc) appendCall(r0 RedisClientPTTLFuncCall) { - f.mutex.Lock() - f.history = append(f.history, r0) - f.mutex.Unlock() -} - -// History returns a sequence of RedisClientPTTLFuncCall objects describing -// the invocations of this function. -func (f *RedisClientPTTLFunc) History() []RedisClientPTTLFuncCall { - f.mutex.Lock() - history := make([]RedisClientPTTLFuncCall, len(f.history)) - copy(history, f.history) - f.mutex.Unlock() - - return history -} - -// RedisClientPTTLFuncCall is an object that describes an invocation of -// method PTTL on an instance of MockRedisClient. -type RedisClientPTTLFuncCall struct { - // Arg0 is the value of the 1st argument passed to this method - // invocation. - Arg0 context.Context - // Arg1 is the value of the 2nd argument passed to this method - // invocation. - Arg1 string - // Result0 is the value of the 1st result returned from this method - // invocation. - Result0 *v9.DurationCmd -} - -// Args returns an interface slice containing the arguments of this -// invocation. -func (c RedisClientPTTLFuncCall) Args() []interface{} { - return []interface{}{c.Arg0, c.Arg1} -} - -// Results returns an interface slice containing the results of this -// invocation. -func (c RedisClientPTTLFuncCall) Results() []interface{} { - return []interface{}{c.Result0} -} - -// RedisClientPersistFunc describes the behavior when the Persist method of -// the parent MockRedisClient instance is invoked. -type RedisClientPersistFunc struct { - defaultHook func(context.Context, string) *v9.BoolCmd - hooks []func(context.Context, string) *v9.BoolCmd - history []RedisClientPersistFuncCall - mutex sync.Mutex -} - -// Persist delegates to the next hook function in the queue and stores the -// parameter and result values of this invocation. -func (m *MockRedisClient) Persist(v0 context.Context, v1 string) *v9.BoolCmd { - r0 := m.PersistFunc.nextHook()(v0, v1) - m.PersistFunc.appendCall(RedisClientPersistFuncCall{v0, v1, r0}) - return r0 -} - -// SetDefaultHook sets function that is called when the Persist method of -// the parent MockRedisClient instance is invoked and the hook queue is -// empty. -func (f *RedisClientPersistFunc) SetDefaultHook(hook func(context.Context, string) *v9.BoolCmd) { - f.defaultHook = hook -} - -// PushHook adds a function to the end of hook queue. Each invocation of the -// Persist method of the parent MockRedisClient instance invokes the hook at -// the front of the queue and discards it. After the queue is empty, the -// default hook function is invoked for any future action. -func (f *RedisClientPersistFunc) PushHook(hook func(context.Context, string) *v9.BoolCmd) { - f.mutex.Lock() - f.hooks = append(f.hooks, hook) - f.mutex.Unlock() -} - -// SetDefaultReturn calls SetDefaultHook with a function that returns the -// given values. -func (f *RedisClientPersistFunc) SetDefaultReturn(r0 *v9.BoolCmd) { - f.SetDefaultHook(func(context.Context, string) *v9.BoolCmd { - return r0 - }) -} - -// PushReturn calls PushHook with a function that returns the given values. -func (f *RedisClientPersistFunc) PushReturn(r0 *v9.BoolCmd) { - f.PushHook(func(context.Context, string) *v9.BoolCmd { - return r0 - }) -} - -func (f *RedisClientPersistFunc) nextHook() func(context.Context, string) *v9.BoolCmd { - f.mutex.Lock() - defer f.mutex.Unlock() - - if len(f.hooks) == 0 { - return f.defaultHook - } - - hook := f.hooks[0] - f.hooks = f.hooks[1:] - return hook -} - -func (f *RedisClientPersistFunc) appendCall(r0 RedisClientPersistFuncCall) { - f.mutex.Lock() - f.history = append(f.history, r0) - f.mutex.Unlock() -} - -// History returns a sequence of RedisClientPersistFuncCall objects -// describing the invocations of this function. -func (f *RedisClientPersistFunc) History() []RedisClientPersistFuncCall { - f.mutex.Lock() - history := make([]RedisClientPersistFuncCall, len(f.history)) - copy(history, f.history) - f.mutex.Unlock() - - return history -} - -// RedisClientPersistFuncCall is an object that describes an invocation of -// method Persist on an instance of MockRedisClient. -type RedisClientPersistFuncCall struct { - // Arg0 is the value of the 1st argument passed to this method - // invocation. - Arg0 context.Context - // Arg1 is the value of the 2nd argument passed to this method - // invocation. - Arg1 string - // Result0 is the value of the 1st result returned from this method - // invocation. - Result0 *v9.BoolCmd -} - -// Args returns an interface slice containing the arguments of this -// invocation. -func (c RedisClientPersistFuncCall) Args() []interface{} { - return []interface{}{c.Arg0, c.Arg1} -} - -// Results returns an interface slice containing the results of this -// invocation. -func (c RedisClientPersistFuncCall) Results() []interface{} { - return []interface{}{c.Result0} -} - -// RedisClientRandomKeyFunc describes the behavior when the RandomKey method -// of the parent MockRedisClient instance is invoked. -type RedisClientRandomKeyFunc struct { - defaultHook func(context.Context) *v9.StringCmd - hooks []func(context.Context) *v9.StringCmd - history []RedisClientRandomKeyFuncCall - mutex sync.Mutex -} - -// RandomKey delegates to the next hook function in the queue and stores the -// parameter and result values of this invocation. -func (m *MockRedisClient) RandomKey(v0 context.Context) *v9.StringCmd { - r0 := m.RandomKeyFunc.nextHook()(v0) - m.RandomKeyFunc.appendCall(RedisClientRandomKeyFuncCall{v0, r0}) - return r0 -} - -// SetDefaultHook sets function that is called when the RandomKey method of -// the parent MockRedisClient instance is invoked and the hook queue is -// empty. -func (f *RedisClientRandomKeyFunc) SetDefaultHook(hook func(context.Context) *v9.StringCmd) { - f.defaultHook = hook -} - -// PushHook adds a function to the end of hook queue. Each invocation of the -// RandomKey method of the parent MockRedisClient instance invokes the hook -// at the front of the queue and discards it. After the queue is empty, the -// default hook function is invoked for any future action. -func (f *RedisClientRandomKeyFunc) PushHook(hook func(context.Context) *v9.StringCmd) { - f.mutex.Lock() - f.hooks = append(f.hooks, hook) - f.mutex.Unlock() -} - -// SetDefaultReturn calls SetDefaultHook with a function that returns the -// given values. -func (f *RedisClientRandomKeyFunc) SetDefaultReturn(r0 *v9.StringCmd) { - f.SetDefaultHook(func(context.Context) *v9.StringCmd { - return r0 - }) -} - -// PushReturn calls PushHook with a function that returns the given values. -func (f *RedisClientRandomKeyFunc) PushReturn(r0 *v9.StringCmd) { - f.PushHook(func(context.Context) *v9.StringCmd { - return r0 - }) -} - -func (f *RedisClientRandomKeyFunc) nextHook() func(context.Context) *v9.StringCmd { - f.mutex.Lock() - defer f.mutex.Unlock() - - if len(f.hooks) == 0 { - return f.defaultHook - } - - hook := f.hooks[0] - f.hooks = f.hooks[1:] - return hook -} - -func (f *RedisClientRandomKeyFunc) appendCall(r0 RedisClientRandomKeyFuncCall) { - f.mutex.Lock() - f.history = append(f.history, r0) - f.mutex.Unlock() -} - -// History returns a sequence of RedisClientRandomKeyFuncCall objects -// describing the invocations of this function. -func (f *RedisClientRandomKeyFunc) History() []RedisClientRandomKeyFuncCall { - f.mutex.Lock() - history := make([]RedisClientRandomKeyFuncCall, len(f.history)) - copy(history, f.history) - f.mutex.Unlock() - - return history -} - -// RedisClientRandomKeyFuncCall is an object that describes an invocation of -// method RandomKey on an instance of MockRedisClient. -type RedisClientRandomKeyFuncCall struct { - // Arg0 is the value of the 1st argument passed to this method - // invocation. - Arg0 context.Context - // Result0 is the value of the 1st result returned from this method - // invocation. - Result0 *v9.StringCmd -} - -// Args returns an interface slice containing the arguments of this -// invocation. -func (c RedisClientRandomKeyFuncCall) Args() []interface{} { - return []interface{}{c.Arg0} -} - -// Results returns an interface slice containing the results of this -// invocation. -func (c RedisClientRandomKeyFuncCall) Results() []interface{} { - return []interface{}{c.Result0} -} - -// RedisClientRenameFunc describes the behavior when the Rename method of -// the parent MockRedisClient instance is invoked. -type RedisClientRenameFunc struct { - defaultHook func(context.Context, string, string) *v9.StatusCmd - hooks []func(context.Context, string, string) *v9.StatusCmd - history []RedisClientRenameFuncCall - mutex sync.Mutex -} - -// Rename delegates to the next hook function in the queue and stores the -// parameter and result values of this invocation. -func (m *MockRedisClient) Rename(v0 context.Context, v1 string, v2 string) *v9.StatusCmd { - r0 := m.RenameFunc.nextHook()(v0, v1, v2) - m.RenameFunc.appendCall(RedisClientRenameFuncCall{v0, v1, v2, r0}) - return r0 -} - -// SetDefaultHook sets function that is called when the Rename method of the -// parent MockRedisClient instance is invoked and the hook queue is empty. -func (f *RedisClientRenameFunc) SetDefaultHook(hook func(context.Context, string, string) *v9.StatusCmd) { - f.defaultHook = hook -} - -// PushHook adds a function to the end of hook queue. Each invocation of the -// Rename method of the parent MockRedisClient instance invokes the hook at -// the front of the queue and discards it. After the queue is empty, the -// default hook function is invoked for any future action. -func (f *RedisClientRenameFunc) PushHook(hook func(context.Context, string, string) *v9.StatusCmd) { - f.mutex.Lock() - f.hooks = append(f.hooks, hook) - f.mutex.Unlock() -} - -// SetDefaultReturn calls SetDefaultHook with a function that returns the -// given values. -func (f *RedisClientRenameFunc) SetDefaultReturn(r0 *v9.StatusCmd) { - f.SetDefaultHook(func(context.Context, string, string) *v9.StatusCmd { - return r0 - }) -} - -// PushReturn calls PushHook with a function that returns the given values. -func (f *RedisClientRenameFunc) PushReturn(r0 *v9.StatusCmd) { - f.PushHook(func(context.Context, string, string) *v9.StatusCmd { - return r0 - }) -} - -func (f *RedisClientRenameFunc) nextHook() func(context.Context, string, string) *v9.StatusCmd { - f.mutex.Lock() - defer f.mutex.Unlock() - - if len(f.hooks) == 0 { - return f.defaultHook - } - - hook := f.hooks[0] - f.hooks = f.hooks[1:] - return hook -} - -func (f *RedisClientRenameFunc) appendCall(r0 RedisClientRenameFuncCall) { - f.mutex.Lock() - f.history = append(f.history, r0) - f.mutex.Unlock() -} - -// History returns a sequence of RedisClientRenameFuncCall objects -// describing the invocations of this function. -func (f *RedisClientRenameFunc) History() []RedisClientRenameFuncCall { - f.mutex.Lock() - history := make([]RedisClientRenameFuncCall, len(f.history)) - copy(history, f.history) - f.mutex.Unlock() - - return history -} - -// RedisClientRenameFuncCall is an object that describes an invocation of -// method Rename on an instance of MockRedisClient. -type RedisClientRenameFuncCall struct { - // Arg0 is the value of the 1st argument passed to this method - // invocation. - Arg0 context.Context - // Arg1 is the value of the 2nd argument passed to this method - // invocation. - Arg1 string - // Arg2 is the value of the 3rd argument passed to this method - // invocation. - Arg2 string - // Result0 is the value of the 1st result returned from this method - // invocation. - Result0 *v9.StatusCmd -} - -// Args returns an interface slice containing the arguments of this -// invocation. -func (c RedisClientRenameFuncCall) Args() []interface{} { - return []interface{}{c.Arg0, c.Arg1, c.Arg2} -} - -// Results returns an interface slice containing the results of this -// invocation. -func (c RedisClientRenameFuncCall) Results() []interface{} { - return []interface{}{c.Result0} -} - -// RedisClientRenameNXFunc describes the behavior when the RenameNX method -// of the parent MockRedisClient instance is invoked. -type RedisClientRenameNXFunc struct { - defaultHook func(context.Context, string, string) *v9.BoolCmd - hooks []func(context.Context, string, string) *v9.BoolCmd - history []RedisClientRenameNXFuncCall - mutex sync.Mutex -} - -// RenameNX delegates to the next hook function in the queue and stores the -// parameter and result values of this invocation. -func (m *MockRedisClient) RenameNX(v0 context.Context, v1 string, v2 string) *v9.BoolCmd { - r0 := m.RenameNXFunc.nextHook()(v0, v1, v2) - m.RenameNXFunc.appendCall(RedisClientRenameNXFuncCall{v0, v1, v2, r0}) - return r0 -} - -// SetDefaultHook sets function that is called when the RenameNX method of -// the parent MockRedisClient instance is invoked and the hook queue is -// empty. -func (f *RedisClientRenameNXFunc) SetDefaultHook(hook func(context.Context, string, string) *v9.BoolCmd) { - f.defaultHook = hook -} - -// PushHook adds a function to the end of hook queue. Each invocation of the -// RenameNX method of the parent MockRedisClient instance invokes the hook -// at the front of the queue and discards it. After the queue is empty, the -// default hook function is invoked for any future action. -func (f *RedisClientRenameNXFunc) PushHook(hook func(context.Context, string, string) *v9.BoolCmd) { - f.mutex.Lock() - f.hooks = append(f.hooks, hook) - f.mutex.Unlock() -} - -// SetDefaultReturn calls SetDefaultHook with a function that returns the -// given values. -func (f *RedisClientRenameNXFunc) SetDefaultReturn(r0 *v9.BoolCmd) { - f.SetDefaultHook(func(context.Context, string, string) *v9.BoolCmd { - return r0 - }) -} - -// PushReturn calls PushHook with a function that returns the given values. -func (f *RedisClientRenameNXFunc) PushReturn(r0 *v9.BoolCmd) { - f.PushHook(func(context.Context, string, string) *v9.BoolCmd { - return r0 - }) -} - -func (f *RedisClientRenameNXFunc) nextHook() func(context.Context, string, string) *v9.BoolCmd { - f.mutex.Lock() - defer f.mutex.Unlock() - - if len(f.hooks) == 0 { - return f.defaultHook - } - - hook := f.hooks[0] - f.hooks = f.hooks[1:] - return hook -} - -func (f *RedisClientRenameNXFunc) appendCall(r0 RedisClientRenameNXFuncCall) { - f.mutex.Lock() - f.history = append(f.history, r0) - f.mutex.Unlock() -} - -// History returns a sequence of RedisClientRenameNXFuncCall objects -// describing the invocations of this function. -func (f *RedisClientRenameNXFunc) History() []RedisClientRenameNXFuncCall { - f.mutex.Lock() - history := make([]RedisClientRenameNXFuncCall, len(f.history)) - copy(history, f.history) - f.mutex.Unlock() - - return history -} - -// RedisClientRenameNXFuncCall is an object that describes an invocation of -// method RenameNX on an instance of MockRedisClient. -type RedisClientRenameNXFuncCall struct { - // Arg0 is the value of the 1st argument passed to this method - // invocation. - Arg0 context.Context - // Arg1 is the value of the 2nd argument passed to this method - // invocation. - Arg1 string - // Arg2 is the value of the 3rd argument passed to this method - // invocation. - Arg2 string - // Result0 is the value of the 1st result returned from this method - // invocation. - Result0 *v9.BoolCmd -} - -// Args returns an interface slice containing the arguments of this -// invocation. -func (c RedisClientRenameNXFuncCall) Args() []interface{} { - return []interface{}{c.Arg0, c.Arg1, c.Arg2} -} - -// Results returns an interface slice containing the results of this -// invocation. -func (c RedisClientRenameNXFuncCall) Results() []interface{} { - return []interface{}{c.Result0} -} - -// RedisClientRestoreFunc describes the behavior when the Restore method of -// the parent MockRedisClient instance is invoked. -type RedisClientRestoreFunc struct { - defaultHook func(context.Context, string, time.Duration, string) *v9.StatusCmd - hooks []func(context.Context, string, time.Duration, string) *v9.StatusCmd - history []RedisClientRestoreFuncCall - mutex sync.Mutex -} - -// Restore delegates to the next hook function in the queue and stores the -// parameter and result values of this invocation. -func (m *MockRedisClient) Restore(v0 context.Context, v1 string, v2 time.Duration, v3 string) *v9.StatusCmd { - r0 := m.RestoreFunc.nextHook()(v0, v1, v2, v3) - m.RestoreFunc.appendCall(RedisClientRestoreFuncCall{v0, v1, v2, v3, r0}) - return r0 -} - -// SetDefaultHook sets function that is called when the Restore method of -// the parent MockRedisClient instance is invoked and the hook queue is -// empty. -func (f *RedisClientRestoreFunc) SetDefaultHook(hook func(context.Context, string, time.Duration, string) *v9.StatusCmd) { - f.defaultHook = hook -} - -// PushHook adds a function to the end of hook queue. Each invocation of the -// Restore method of the parent MockRedisClient instance invokes the hook at -// the front of the queue and discards it. After the queue is empty, the -// default hook function is invoked for any future action. -func (f *RedisClientRestoreFunc) PushHook(hook func(context.Context, string, time.Duration, string) *v9.StatusCmd) { - f.mutex.Lock() - f.hooks = append(f.hooks, hook) - f.mutex.Unlock() -} - -// SetDefaultReturn calls SetDefaultHook with a function that returns the -// given values. -func (f *RedisClientRestoreFunc) SetDefaultReturn(r0 *v9.StatusCmd) { - f.SetDefaultHook(func(context.Context, string, time.Duration, string) *v9.StatusCmd { - return r0 - }) -} - -// PushReturn calls PushHook with a function that returns the given values. -func (f *RedisClientRestoreFunc) PushReturn(r0 *v9.StatusCmd) { - f.PushHook(func(context.Context, string, time.Duration, string) *v9.StatusCmd { - return r0 - }) -} - -func (f *RedisClientRestoreFunc) nextHook() func(context.Context, string, time.Duration, string) *v9.StatusCmd { - f.mutex.Lock() - defer f.mutex.Unlock() - - if len(f.hooks) == 0 { - return f.defaultHook - } - - hook := f.hooks[0] - f.hooks = f.hooks[1:] - return hook -} - -func (f *RedisClientRestoreFunc) appendCall(r0 RedisClientRestoreFuncCall) { - f.mutex.Lock() - f.history = append(f.history, r0) - f.mutex.Unlock() -} - -// History returns a sequence of RedisClientRestoreFuncCall objects -// describing the invocations of this function. -func (f *RedisClientRestoreFunc) History() []RedisClientRestoreFuncCall { - f.mutex.Lock() - history := make([]RedisClientRestoreFuncCall, len(f.history)) - copy(history, f.history) - f.mutex.Unlock() - - return history -} - -// RedisClientRestoreFuncCall is an object that describes an invocation of -// method Restore on an instance of MockRedisClient. -type RedisClientRestoreFuncCall struct { - // Arg0 is the value of the 1st argument passed to this method - // invocation. - Arg0 context.Context - // Arg1 is the value of the 2nd argument passed to this method - // invocation. - Arg1 string - // Arg2 is the value of the 3rd argument passed to this method - // invocation. - Arg2 time.Duration - // Arg3 is the value of the 4th argument passed to this method - // invocation. - Arg3 string - // Result0 is the value of the 1st result returned from this method - // invocation. - Result0 *v9.StatusCmd -} - -// Args returns an interface slice containing the arguments of this -// invocation. -func (c RedisClientRestoreFuncCall) Args() []interface{} { - return []interface{}{c.Arg0, c.Arg1, c.Arg2, c.Arg3} -} - -// Results returns an interface slice containing the results of this -// invocation. -func (c RedisClientRestoreFuncCall) Results() []interface{} { - return []interface{}{c.Result0} -} - -// RedisClientRestoreReplaceFunc describes the behavior when the -// RestoreReplace method of the parent MockRedisClient instance is invoked. -type RedisClientRestoreReplaceFunc struct { - defaultHook func(context.Context, string, time.Duration, string) *v9.StatusCmd - hooks []func(context.Context, string, time.Duration, string) *v9.StatusCmd - history []RedisClientRestoreReplaceFuncCall - mutex sync.Mutex -} - -// RestoreReplace delegates to the next hook function in the queue and -// stores the parameter and result values of this invocation. -func (m *MockRedisClient) RestoreReplace(v0 context.Context, v1 string, v2 time.Duration, v3 string) *v9.StatusCmd { - r0 := m.RestoreReplaceFunc.nextHook()(v0, v1, v2, v3) - m.RestoreReplaceFunc.appendCall(RedisClientRestoreReplaceFuncCall{v0, v1, v2, v3, r0}) - return r0 -} - -// SetDefaultHook sets function that is called when the RestoreReplace -// method of the parent MockRedisClient instance is invoked and the hook -// queue is empty. -func (f *RedisClientRestoreReplaceFunc) SetDefaultHook(hook func(context.Context, string, time.Duration, string) *v9.StatusCmd) { - f.defaultHook = hook -} - -// PushHook adds a function to the end of hook queue. Each invocation of the -// RestoreReplace method of the parent MockRedisClient instance invokes the -// hook at the front of the queue and discards it. After the queue is empty, -// the default hook function is invoked for any future action. -func (f *RedisClientRestoreReplaceFunc) PushHook(hook func(context.Context, string, time.Duration, string) *v9.StatusCmd) { - f.mutex.Lock() - f.hooks = append(f.hooks, hook) - f.mutex.Unlock() -} - -// SetDefaultReturn calls SetDefaultHook with a function that returns the -// given values. -func (f *RedisClientRestoreReplaceFunc) SetDefaultReturn(r0 *v9.StatusCmd) { - f.SetDefaultHook(func(context.Context, string, time.Duration, string) *v9.StatusCmd { - return r0 - }) -} - -// PushReturn calls PushHook with a function that returns the given values. -func (f *RedisClientRestoreReplaceFunc) PushReturn(r0 *v9.StatusCmd) { - f.PushHook(func(context.Context, string, time.Duration, string) *v9.StatusCmd { - return r0 - }) -} - -func (f *RedisClientRestoreReplaceFunc) nextHook() func(context.Context, string, time.Duration, string) *v9.StatusCmd { - f.mutex.Lock() - defer f.mutex.Unlock() - - if len(f.hooks) == 0 { - return f.defaultHook - } - - hook := f.hooks[0] - f.hooks = f.hooks[1:] - return hook -} - -func (f *RedisClientRestoreReplaceFunc) appendCall(r0 RedisClientRestoreReplaceFuncCall) { - f.mutex.Lock() - f.history = append(f.history, r0) - f.mutex.Unlock() -} - -// History returns a sequence of RedisClientRestoreReplaceFuncCall objects -// describing the invocations of this function. -func (f *RedisClientRestoreReplaceFunc) History() []RedisClientRestoreReplaceFuncCall { - f.mutex.Lock() - history := make([]RedisClientRestoreReplaceFuncCall, len(f.history)) - copy(history, f.history) - f.mutex.Unlock() - - return history -} - -// RedisClientRestoreReplaceFuncCall is an object that describes an -// invocation of method RestoreReplace on an instance of MockRedisClient. -type RedisClientRestoreReplaceFuncCall struct { - // Arg0 is the value of the 1st argument passed to this method - // invocation. - Arg0 context.Context - // Arg1 is the value of the 2nd argument passed to this method - // invocation. - Arg1 string - // Arg2 is the value of the 3rd argument passed to this method - // invocation. - Arg2 time.Duration - // Arg3 is the value of the 4th argument passed to this method - // invocation. - Arg3 string - // Result0 is the value of the 1st result returned from this method - // invocation. - Result0 *v9.StatusCmd -} - -// Args returns an interface slice containing the arguments of this -// invocation. -func (c RedisClientRestoreReplaceFuncCall) Args() []interface{} { - return []interface{}{c.Arg0, c.Arg1, c.Arg2, c.Arg3} -} - -// Results returns an interface slice containing the results of this -// invocation. -func (c RedisClientRestoreReplaceFuncCall) Results() []interface{} { - return []interface{}{c.Result0} -} - -// RedisClientScanFunc describes the behavior when the Scan method of the -// parent MockRedisClient instance is invoked. -type RedisClientScanFunc struct { - defaultHook func(context.Context, uint64, string, int64) *v9.ScanCmd - hooks []func(context.Context, uint64, string, int64) *v9.ScanCmd - history []RedisClientScanFuncCall - mutex sync.Mutex -} - -// Scan delegates to the next hook function in the queue and stores the -// parameter and result values of this invocation. -func (m *MockRedisClient) Scan(v0 context.Context, v1 uint64, v2 string, v3 int64) *v9.ScanCmd { - r0 := m.ScanFunc.nextHook()(v0, v1, v2, v3) - m.ScanFunc.appendCall(RedisClientScanFuncCall{v0, v1, v2, v3, r0}) - return r0 -} - -// SetDefaultHook sets function that is called when the Scan method of the -// parent MockRedisClient instance is invoked and the hook queue is empty. -func (f *RedisClientScanFunc) SetDefaultHook(hook func(context.Context, uint64, string, int64) *v9.ScanCmd) { - f.defaultHook = hook -} - -// PushHook adds a function to the end of hook queue. Each invocation of the -// Scan method of the parent MockRedisClient instance invokes the hook at -// the front of the queue and discards it. After the queue is empty, the -// default hook function is invoked for any future action. -func (f *RedisClientScanFunc) PushHook(hook func(context.Context, uint64, string, int64) *v9.ScanCmd) { - f.mutex.Lock() - f.hooks = append(f.hooks, hook) - f.mutex.Unlock() -} - -// SetDefaultReturn calls SetDefaultHook with a function that returns the -// given values. -func (f *RedisClientScanFunc) SetDefaultReturn(r0 *v9.ScanCmd) { - f.SetDefaultHook(func(context.Context, uint64, string, int64) *v9.ScanCmd { - return r0 - }) -} - -// PushReturn calls PushHook with a function that returns the given values. -func (f *RedisClientScanFunc) PushReturn(r0 *v9.ScanCmd) { - f.PushHook(func(context.Context, uint64, string, int64) *v9.ScanCmd { - return r0 - }) -} - -func (f *RedisClientScanFunc) nextHook() func(context.Context, uint64, string, int64) *v9.ScanCmd { - f.mutex.Lock() - defer f.mutex.Unlock() - - if len(f.hooks) == 0 { - return f.defaultHook - } - - hook := f.hooks[0] - f.hooks = f.hooks[1:] - return hook -} - -func (f *RedisClientScanFunc) appendCall(r0 RedisClientScanFuncCall) { - f.mutex.Lock() - f.history = append(f.history, r0) - f.mutex.Unlock() -} - -// History returns a sequence of RedisClientScanFuncCall objects describing -// the invocations of this function. -func (f *RedisClientScanFunc) History() []RedisClientScanFuncCall { - f.mutex.Lock() - history := make([]RedisClientScanFuncCall, len(f.history)) - copy(history, f.history) - f.mutex.Unlock() - - return history -} - -// RedisClientScanFuncCall is an object that describes an invocation of -// method Scan on an instance of MockRedisClient. -type RedisClientScanFuncCall struct { - // Arg0 is the value of the 1st argument passed to this method - // invocation. - Arg0 context.Context - // Arg1 is the value of the 2nd argument passed to this method - // invocation. - Arg1 uint64 - // Arg2 is the value of the 3rd argument passed to this method - // invocation. - Arg2 string - // Arg3 is the value of the 4th argument passed to this method - // invocation. - Arg3 int64 - // Result0 is the value of the 1st result returned from this method - // invocation. - Result0 *v9.ScanCmd -} - -// Args returns an interface slice containing the arguments of this -// invocation. -func (c RedisClientScanFuncCall) Args() []interface{} { - return []interface{}{c.Arg0, c.Arg1, c.Arg2, c.Arg3} -} - -// Results returns an interface slice containing the results of this -// invocation. -func (c RedisClientScanFuncCall) Results() []interface{} { - return []interface{}{c.Result0} -} - -// RedisClientScanTypeFunc describes the behavior when the ScanType method -// of the parent MockRedisClient instance is invoked. -type RedisClientScanTypeFunc struct { - defaultHook func(context.Context, uint64, string, int64, string) *v9.ScanCmd - hooks []func(context.Context, uint64, string, int64, string) *v9.ScanCmd - history []RedisClientScanTypeFuncCall - mutex sync.Mutex -} - -// ScanType delegates to the next hook function in the queue and stores the -// parameter and result values of this invocation. -func (m *MockRedisClient) ScanType(v0 context.Context, v1 uint64, v2 string, v3 int64, v4 string) *v9.ScanCmd { - r0 := m.ScanTypeFunc.nextHook()(v0, v1, v2, v3, v4) - m.ScanTypeFunc.appendCall(RedisClientScanTypeFuncCall{v0, v1, v2, v3, v4, r0}) - return r0 -} - -// SetDefaultHook sets function that is called when the ScanType method of -// the parent MockRedisClient instance is invoked and the hook queue is -// empty. -func (f *RedisClientScanTypeFunc) SetDefaultHook(hook func(context.Context, uint64, string, int64, string) *v9.ScanCmd) { - f.defaultHook = hook -} - -// PushHook adds a function to the end of hook queue. Each invocation of the -// ScanType method of the parent MockRedisClient instance invokes the hook -// at the front of the queue and discards it. After the queue is empty, the -// default hook function is invoked for any future action. -func (f *RedisClientScanTypeFunc) PushHook(hook func(context.Context, uint64, string, int64, string) *v9.ScanCmd) { - f.mutex.Lock() - f.hooks = append(f.hooks, hook) - f.mutex.Unlock() -} - -// SetDefaultReturn calls SetDefaultHook with a function that returns the -// given values. -func (f *RedisClientScanTypeFunc) SetDefaultReturn(r0 *v9.ScanCmd) { - f.SetDefaultHook(func(context.Context, uint64, string, int64, string) *v9.ScanCmd { - return r0 - }) -} - -// PushReturn calls PushHook with a function that returns the given values. -func (f *RedisClientScanTypeFunc) PushReturn(r0 *v9.ScanCmd) { - f.PushHook(func(context.Context, uint64, string, int64, string) *v9.ScanCmd { - return r0 - }) -} - -func (f *RedisClientScanTypeFunc) nextHook() func(context.Context, uint64, string, int64, string) *v9.ScanCmd { - f.mutex.Lock() - defer f.mutex.Unlock() - - if len(f.hooks) == 0 { - return f.defaultHook - } - - hook := f.hooks[0] - f.hooks = f.hooks[1:] - return hook -} - -func (f *RedisClientScanTypeFunc) appendCall(r0 RedisClientScanTypeFuncCall) { - f.mutex.Lock() - f.history = append(f.history, r0) - f.mutex.Unlock() -} - -// History returns a sequence of RedisClientScanTypeFuncCall objects -// describing the invocations of this function. -func (f *RedisClientScanTypeFunc) History() []RedisClientScanTypeFuncCall { - f.mutex.Lock() - history := make([]RedisClientScanTypeFuncCall, len(f.history)) - copy(history, f.history) - f.mutex.Unlock() - - return history -} - -// RedisClientScanTypeFuncCall is an object that describes an invocation of -// method ScanType on an instance of MockRedisClient. -type RedisClientScanTypeFuncCall struct { - // Arg0 is the value of the 1st argument passed to this method - // invocation. - Arg0 context.Context - // Arg1 is the value of the 2nd argument passed to this method - // invocation. - Arg1 uint64 - // Arg2 is the value of the 3rd argument passed to this method - // invocation. - Arg2 string - // Arg3 is the value of the 4th argument passed to this method - // invocation. - Arg3 int64 - // Arg4 is the value of the 5th argument passed to this method - // invocation. - Arg4 string - // Result0 is the value of the 1st result returned from this method - // invocation. - Result0 *v9.ScanCmd -} - -// Args returns an interface slice containing the arguments of this -// invocation. -func (c RedisClientScanTypeFuncCall) Args() []interface{} { - return []interface{}{c.Arg0, c.Arg1, c.Arg2, c.Arg3, c.Arg4} -} - -// Results returns an interface slice containing the results of this -// invocation. -func (c RedisClientScanTypeFuncCall) Results() []interface{} { - return []interface{}{c.Result0} -} - -// RedisClientSetFunc describes the behavior when the Set method of the -// parent MockRedisClient instance is invoked. -type RedisClientSetFunc struct { - defaultHook func(context.Context, string, interface{}, time.Duration) *v9.StatusCmd - hooks []func(context.Context, string, interface{}, time.Duration) *v9.StatusCmd - history []RedisClientSetFuncCall - mutex sync.Mutex -} - -// Set delegates to the next hook function in the queue and stores the -// parameter and result values of this invocation. -func (m *MockRedisClient) Set(v0 context.Context, v1 string, v2 interface{}, v3 time.Duration) *v9.StatusCmd { - r0 := m.SetFunc.nextHook()(v0, v1, v2, v3) - m.SetFunc.appendCall(RedisClientSetFuncCall{v0, v1, v2, v3, r0}) - return r0 -} - -// SetDefaultHook sets function that is called when the Set method of the -// parent MockRedisClient instance is invoked and the hook queue is empty. -func (f *RedisClientSetFunc) SetDefaultHook(hook func(context.Context, string, interface{}, time.Duration) *v9.StatusCmd) { - f.defaultHook = hook -} - -// PushHook adds a function to the end of hook queue. Each invocation of the -// Set method of the parent MockRedisClient instance invokes the hook at the -// front of the queue and discards it. After the queue is empty, the default -// hook function is invoked for any future action. -func (f *RedisClientSetFunc) PushHook(hook func(context.Context, string, interface{}, time.Duration) *v9.StatusCmd) { - f.mutex.Lock() - f.hooks = append(f.hooks, hook) - f.mutex.Unlock() -} - -// SetDefaultReturn calls SetDefaultHook with a function that returns the -// given values. -func (f *RedisClientSetFunc) SetDefaultReturn(r0 *v9.StatusCmd) { - f.SetDefaultHook(func(context.Context, string, interface{}, time.Duration) *v9.StatusCmd { - return r0 - }) -} - -// PushReturn calls PushHook with a function that returns the given values. -func (f *RedisClientSetFunc) PushReturn(r0 *v9.StatusCmd) { - f.PushHook(func(context.Context, string, interface{}, time.Duration) *v9.StatusCmd { - return r0 - }) -} - -func (f *RedisClientSetFunc) nextHook() func(context.Context, string, interface{}, time.Duration) *v9.StatusCmd { - f.mutex.Lock() - defer f.mutex.Unlock() - - if len(f.hooks) == 0 { - return f.defaultHook - } - - hook := f.hooks[0] - f.hooks = f.hooks[1:] - return hook -} - -func (f *RedisClientSetFunc) appendCall(r0 RedisClientSetFuncCall) { - f.mutex.Lock() - f.history = append(f.history, r0) - f.mutex.Unlock() -} - -// History returns a sequence of RedisClientSetFuncCall objects describing -// the invocations of this function. -func (f *RedisClientSetFunc) History() []RedisClientSetFuncCall { - f.mutex.Lock() - history := make([]RedisClientSetFuncCall, len(f.history)) - copy(history, f.history) - f.mutex.Unlock() - - return history -} - -// RedisClientSetFuncCall is an object that describes an invocation of -// method Set on an instance of MockRedisClient. -type RedisClientSetFuncCall struct { - // Arg0 is the value of the 1st argument passed to this method - // invocation. - Arg0 context.Context - // Arg1 is the value of the 2nd argument passed to this method - // invocation. - Arg1 string - // Arg2 is the value of the 3rd argument passed to this method - // invocation. - Arg2 interface{} - // Arg3 is the value of the 4th argument passed to this method - // invocation. - Arg3 time.Duration - // Result0 is the value of the 1st result returned from this method - // invocation. - Result0 *v9.StatusCmd -} - -// Args returns an interface slice containing the arguments of this -// invocation. -func (c RedisClientSetFuncCall) Args() []interface{} { - return []interface{}{c.Arg0, c.Arg1, c.Arg2, c.Arg3} -} - -// Results returns an interface slice containing the results of this -// invocation. -func (c RedisClientSetFuncCall) Results() []interface{} { - return []interface{}{c.Result0} -} - -// RedisClientSetArgsFunc describes the behavior when the SetArgs method of -// the parent MockRedisClient instance is invoked. -type RedisClientSetArgsFunc struct { - defaultHook func(context.Context, string, interface{}, v9.SetArgs) *v9.StatusCmd - hooks []func(context.Context, string, interface{}, v9.SetArgs) *v9.StatusCmd - history []RedisClientSetArgsFuncCall - mutex sync.Mutex -} - -// SetArgs delegates to the next hook function in the queue and stores the -// parameter and result values of this invocation. -func (m *MockRedisClient) SetArgs(v0 context.Context, v1 string, v2 interface{}, v3 v9.SetArgs) *v9.StatusCmd { - r0 := m.SetArgsFunc.nextHook()(v0, v1, v2, v3) - m.SetArgsFunc.appendCall(RedisClientSetArgsFuncCall{v0, v1, v2, v3, r0}) - return r0 -} - -// SetDefaultHook sets function that is called when the SetArgs method of -// the parent MockRedisClient instance is invoked and the hook queue is -// empty. -func (f *RedisClientSetArgsFunc) SetDefaultHook(hook func(context.Context, string, interface{}, v9.SetArgs) *v9.StatusCmd) { - f.defaultHook = hook -} - -// PushHook adds a function to the end of hook queue. Each invocation of the -// SetArgs method of the parent MockRedisClient instance invokes the hook at -// the front of the queue and discards it. After the queue is empty, the -// default hook function is invoked for any future action. -func (f *RedisClientSetArgsFunc) PushHook(hook func(context.Context, string, interface{}, v9.SetArgs) *v9.StatusCmd) { - f.mutex.Lock() - f.hooks = append(f.hooks, hook) - f.mutex.Unlock() -} - -// SetDefaultReturn calls SetDefaultHook with a function that returns the -// given values. -func (f *RedisClientSetArgsFunc) SetDefaultReturn(r0 *v9.StatusCmd) { - f.SetDefaultHook(func(context.Context, string, interface{}, v9.SetArgs) *v9.StatusCmd { - return r0 - }) -} - -// PushReturn calls PushHook with a function that returns the given values. -func (f *RedisClientSetArgsFunc) PushReturn(r0 *v9.StatusCmd) { - f.PushHook(func(context.Context, string, interface{}, v9.SetArgs) *v9.StatusCmd { - return r0 - }) -} - -func (f *RedisClientSetArgsFunc) nextHook() func(context.Context, string, interface{}, v9.SetArgs) *v9.StatusCmd { - f.mutex.Lock() - defer f.mutex.Unlock() - - if len(f.hooks) == 0 { - return f.defaultHook - } - - hook := f.hooks[0] - f.hooks = f.hooks[1:] - return hook -} - -func (f *RedisClientSetArgsFunc) appendCall(r0 RedisClientSetArgsFuncCall) { - f.mutex.Lock() - f.history = append(f.history, r0) - f.mutex.Unlock() -} - -// History returns a sequence of RedisClientSetArgsFuncCall objects -// describing the invocations of this function. -func (f *RedisClientSetArgsFunc) History() []RedisClientSetArgsFuncCall { - f.mutex.Lock() - history := make([]RedisClientSetArgsFuncCall, len(f.history)) - copy(history, f.history) - f.mutex.Unlock() - - return history -} - -// RedisClientSetArgsFuncCall is an object that describes an invocation of -// method SetArgs on an instance of MockRedisClient. -type RedisClientSetArgsFuncCall struct { - // Arg0 is the value of the 1st argument passed to this method - // invocation. - Arg0 context.Context - // Arg1 is the value of the 2nd argument passed to this method - // invocation. - Arg1 string - // Arg2 is the value of the 3rd argument passed to this method - // invocation. - Arg2 interface{} - // Arg3 is the value of the 4th argument passed to this method - // invocation. - Arg3 v9.SetArgs - // Result0 is the value of the 1st result returned from this method - // invocation. - Result0 *v9.StatusCmd -} - -// Args returns an interface slice containing the arguments of this -// invocation. -func (c RedisClientSetArgsFuncCall) Args() []interface{} { - return []interface{}{c.Arg0, c.Arg1, c.Arg2, c.Arg3} -} - -// Results returns an interface slice containing the results of this -// invocation. -func (c RedisClientSetArgsFuncCall) Results() []interface{} { - return []interface{}{c.Result0} -} - -// RedisClientSetExFunc describes the behavior when the SetEx method of the -// parent MockRedisClient instance is invoked. -type RedisClientSetExFunc struct { - defaultHook func(context.Context, string, interface{}, time.Duration) *v9.StatusCmd - hooks []func(context.Context, string, interface{}, time.Duration) *v9.StatusCmd - history []RedisClientSetExFuncCall - mutex sync.Mutex -} - -// SetEx delegates to the next hook function in the queue and stores the -// parameter and result values of this invocation. -func (m *MockRedisClient) SetEx(v0 context.Context, v1 string, v2 interface{}, v3 time.Duration) *v9.StatusCmd { - r0 := m.SetExFunc.nextHook()(v0, v1, v2, v3) - m.SetExFunc.appendCall(RedisClientSetExFuncCall{v0, v1, v2, v3, r0}) - return r0 -} - -// SetDefaultHook sets function that is called when the SetEx method of the -// parent MockRedisClient instance is invoked and the hook queue is empty. -func (f *RedisClientSetExFunc) SetDefaultHook(hook func(context.Context, string, interface{}, time.Duration) *v9.StatusCmd) { - f.defaultHook = hook -} - -// PushHook adds a function to the end of hook queue. Each invocation of the -// SetEx method of the parent MockRedisClient instance invokes the hook at -// the front of the queue and discards it. After the queue is empty, the -// default hook function is invoked for any future action. -func (f *RedisClientSetExFunc) PushHook(hook func(context.Context, string, interface{}, time.Duration) *v9.StatusCmd) { - f.mutex.Lock() - f.hooks = append(f.hooks, hook) - f.mutex.Unlock() -} - -// SetDefaultReturn calls SetDefaultHook with a function that returns the -// given values. -func (f *RedisClientSetExFunc) SetDefaultReturn(r0 *v9.StatusCmd) { - f.SetDefaultHook(func(context.Context, string, interface{}, time.Duration) *v9.StatusCmd { - return r0 - }) -} - -// PushReturn calls PushHook with a function that returns the given values. -func (f *RedisClientSetExFunc) PushReturn(r0 *v9.StatusCmd) { - f.PushHook(func(context.Context, string, interface{}, time.Duration) *v9.StatusCmd { - return r0 - }) -} - -func (f *RedisClientSetExFunc) nextHook() func(context.Context, string, interface{}, time.Duration) *v9.StatusCmd { - f.mutex.Lock() - defer f.mutex.Unlock() - - if len(f.hooks) == 0 { - return f.defaultHook - } - - hook := f.hooks[0] - f.hooks = f.hooks[1:] - return hook -} - -func (f *RedisClientSetExFunc) appendCall(r0 RedisClientSetExFuncCall) { - f.mutex.Lock() - f.history = append(f.history, r0) - f.mutex.Unlock() -} - -// History returns a sequence of RedisClientSetExFuncCall objects describing -// the invocations of this function. -func (f *RedisClientSetExFunc) History() []RedisClientSetExFuncCall { - f.mutex.Lock() - history := make([]RedisClientSetExFuncCall, len(f.history)) - copy(history, f.history) - f.mutex.Unlock() - - return history -} - -// RedisClientSetExFuncCall is an object that describes an invocation of -// method SetEx on an instance of MockRedisClient. -type RedisClientSetExFuncCall struct { - // Arg0 is the value of the 1st argument passed to this method - // invocation. - Arg0 context.Context - // Arg1 is the value of the 2nd argument passed to this method - // invocation. - Arg1 string - // Arg2 is the value of the 3rd argument passed to this method - // invocation. - Arg2 interface{} - // Arg3 is the value of the 4th argument passed to this method - // invocation. - Arg3 time.Duration - // Result0 is the value of the 1st result returned from this method - // invocation. - Result0 *v9.StatusCmd -} - -// Args returns an interface slice containing the arguments of this -// invocation. -func (c RedisClientSetExFuncCall) Args() []interface{} { - return []interface{}{c.Arg0, c.Arg1, c.Arg2, c.Arg3} -} - -// Results returns an interface slice containing the results of this -// invocation. -func (c RedisClientSetExFuncCall) Results() []interface{} { - return []interface{}{c.Result0} -} - -// RedisClientSetNXFunc describes the behavior when the SetNX method of the -// parent MockRedisClient instance is invoked. -type RedisClientSetNXFunc struct { - defaultHook func(context.Context, string, interface{}, time.Duration) *v9.BoolCmd - hooks []func(context.Context, string, interface{}, time.Duration) *v9.BoolCmd - history []RedisClientSetNXFuncCall - mutex sync.Mutex -} - -// SetNX delegates to the next hook function in the queue and stores the -// parameter and result values of this invocation. -func (m *MockRedisClient) SetNX(v0 context.Context, v1 string, v2 interface{}, v3 time.Duration) *v9.BoolCmd { - r0 := m.SetNXFunc.nextHook()(v0, v1, v2, v3) - m.SetNXFunc.appendCall(RedisClientSetNXFuncCall{v0, v1, v2, v3, r0}) - return r0 -} - -// SetDefaultHook sets function that is called when the SetNX method of the -// parent MockRedisClient instance is invoked and the hook queue is empty. -func (f *RedisClientSetNXFunc) SetDefaultHook(hook func(context.Context, string, interface{}, time.Duration) *v9.BoolCmd) { - f.defaultHook = hook -} - -// PushHook adds a function to the end of hook queue. Each invocation of the -// SetNX method of the parent MockRedisClient instance invokes the hook at -// the front of the queue and discards it. After the queue is empty, the -// default hook function is invoked for any future action. -func (f *RedisClientSetNXFunc) PushHook(hook func(context.Context, string, interface{}, time.Duration) *v9.BoolCmd) { - f.mutex.Lock() - f.hooks = append(f.hooks, hook) - f.mutex.Unlock() -} - -// SetDefaultReturn calls SetDefaultHook with a function that returns the -// given values. -func (f *RedisClientSetNXFunc) SetDefaultReturn(r0 *v9.BoolCmd) { - f.SetDefaultHook(func(context.Context, string, interface{}, time.Duration) *v9.BoolCmd { - return r0 - }) -} - -// PushReturn calls PushHook with a function that returns the given values. -func (f *RedisClientSetNXFunc) PushReturn(r0 *v9.BoolCmd) { - f.PushHook(func(context.Context, string, interface{}, time.Duration) *v9.BoolCmd { - return r0 - }) -} - -func (f *RedisClientSetNXFunc) nextHook() func(context.Context, string, interface{}, time.Duration) *v9.BoolCmd { - f.mutex.Lock() - defer f.mutex.Unlock() - - if len(f.hooks) == 0 { - return f.defaultHook - } - - hook := f.hooks[0] - f.hooks = f.hooks[1:] - return hook -} - -func (f *RedisClientSetNXFunc) appendCall(r0 RedisClientSetNXFuncCall) { - f.mutex.Lock() - f.history = append(f.history, r0) - f.mutex.Unlock() -} - -// History returns a sequence of RedisClientSetNXFuncCall objects describing -// the invocations of this function. -func (f *RedisClientSetNXFunc) History() []RedisClientSetNXFuncCall { - f.mutex.Lock() - history := make([]RedisClientSetNXFuncCall, len(f.history)) - copy(history, f.history) - f.mutex.Unlock() - - return history -} - -// RedisClientSetNXFuncCall is an object that describes an invocation of -// method SetNX on an instance of MockRedisClient. -type RedisClientSetNXFuncCall struct { - // Arg0 is the value of the 1st argument passed to this method - // invocation. - Arg0 context.Context - // Arg1 is the value of the 2nd argument passed to this method - // invocation. - Arg1 string - // Arg2 is the value of the 3rd argument passed to this method - // invocation. - Arg2 interface{} - // Arg3 is the value of the 4th argument passed to this method - // invocation. - Arg3 time.Duration - // Result0 is the value of the 1st result returned from this method - // invocation. - Result0 *v9.BoolCmd -} - -// Args returns an interface slice containing the arguments of this -// invocation. -func (c RedisClientSetNXFuncCall) Args() []interface{} { - return []interface{}{c.Arg0, c.Arg1, c.Arg2, c.Arg3} -} - -// Results returns an interface slice containing the results of this -// invocation. -func (c RedisClientSetNXFuncCall) Results() []interface{} { - return []interface{}{c.Result0} -} - -// RedisClientSetRangeFunc describes the behavior when the SetRange method -// of the parent MockRedisClient instance is invoked. -type RedisClientSetRangeFunc struct { - defaultHook func(context.Context, string, int64, string) *v9.IntCmd - hooks []func(context.Context, string, int64, string) *v9.IntCmd - history []RedisClientSetRangeFuncCall - mutex sync.Mutex -} - -// SetRange delegates to the next hook function in the queue and stores the -// parameter and result values of this invocation. -func (m *MockRedisClient) SetRange(v0 context.Context, v1 string, v2 int64, v3 string) *v9.IntCmd { - r0 := m.SetRangeFunc.nextHook()(v0, v1, v2, v3) - m.SetRangeFunc.appendCall(RedisClientSetRangeFuncCall{v0, v1, v2, v3, r0}) - return r0 -} - -// SetDefaultHook sets function that is called when the SetRange method of -// the parent MockRedisClient instance is invoked and the hook queue is -// empty. -func (f *RedisClientSetRangeFunc) SetDefaultHook(hook func(context.Context, string, int64, string) *v9.IntCmd) { - f.defaultHook = hook -} - -// PushHook adds a function to the end of hook queue. Each invocation of the -// SetRange method of the parent MockRedisClient instance invokes the hook -// at the front of the queue and discards it. After the queue is empty, the -// default hook function is invoked for any future action. -func (f *RedisClientSetRangeFunc) PushHook(hook func(context.Context, string, int64, string) *v9.IntCmd) { - f.mutex.Lock() - f.hooks = append(f.hooks, hook) - f.mutex.Unlock() -} - -// SetDefaultReturn calls SetDefaultHook with a function that returns the -// given values. -func (f *RedisClientSetRangeFunc) SetDefaultReturn(r0 *v9.IntCmd) { - f.SetDefaultHook(func(context.Context, string, int64, string) *v9.IntCmd { - return r0 - }) -} - -// PushReturn calls PushHook with a function that returns the given values. -func (f *RedisClientSetRangeFunc) PushReturn(r0 *v9.IntCmd) { - f.PushHook(func(context.Context, string, int64, string) *v9.IntCmd { - return r0 - }) -} - -func (f *RedisClientSetRangeFunc) nextHook() func(context.Context, string, int64, string) *v9.IntCmd { - f.mutex.Lock() - defer f.mutex.Unlock() - - if len(f.hooks) == 0 { - return f.defaultHook - } - - hook := f.hooks[0] - f.hooks = f.hooks[1:] - return hook -} - -func (f *RedisClientSetRangeFunc) appendCall(r0 RedisClientSetRangeFuncCall) { - f.mutex.Lock() - f.history = append(f.history, r0) - f.mutex.Unlock() -} - -// History returns a sequence of RedisClientSetRangeFuncCall objects -// describing the invocations of this function. -func (f *RedisClientSetRangeFunc) History() []RedisClientSetRangeFuncCall { - f.mutex.Lock() - history := make([]RedisClientSetRangeFuncCall, len(f.history)) - copy(history, f.history) - f.mutex.Unlock() - - return history -} - -// RedisClientSetRangeFuncCall is an object that describes an invocation of -// method SetRange on an instance of MockRedisClient. -type RedisClientSetRangeFuncCall struct { - // Arg0 is the value of the 1st argument passed to this method - // invocation. - Arg0 context.Context - // Arg1 is the value of the 2nd argument passed to this method - // invocation. - Arg1 string - // Arg2 is the value of the 3rd argument passed to this method - // invocation. - Arg2 int64 - // Arg3 is the value of the 4th argument passed to this method - // invocation. - Arg3 string - // Result0 is the value of the 1st result returned from this method - // invocation. - Result0 *v9.IntCmd -} - -// Args returns an interface slice containing the arguments of this -// invocation. -func (c RedisClientSetRangeFuncCall) Args() []interface{} { - return []interface{}{c.Arg0, c.Arg1, c.Arg2, c.Arg3} -} - -// Results returns an interface slice containing the results of this -// invocation. -func (c RedisClientSetRangeFuncCall) Results() []interface{} { - return []interface{}{c.Result0} -} - -// RedisClientSetXXFunc describes the behavior when the SetXX method of the -// parent MockRedisClient instance is invoked. -type RedisClientSetXXFunc struct { - defaultHook func(context.Context, string, interface{}, time.Duration) *v9.BoolCmd - hooks []func(context.Context, string, interface{}, time.Duration) *v9.BoolCmd - history []RedisClientSetXXFuncCall - mutex sync.Mutex -} - -// SetXX delegates to the next hook function in the queue and stores the -// parameter and result values of this invocation. -func (m *MockRedisClient) SetXX(v0 context.Context, v1 string, v2 interface{}, v3 time.Duration) *v9.BoolCmd { - r0 := m.SetXXFunc.nextHook()(v0, v1, v2, v3) - m.SetXXFunc.appendCall(RedisClientSetXXFuncCall{v0, v1, v2, v3, r0}) - return r0 -} - -// SetDefaultHook sets function that is called when the SetXX method of the -// parent MockRedisClient instance is invoked and the hook queue is empty. -func (f *RedisClientSetXXFunc) SetDefaultHook(hook func(context.Context, string, interface{}, time.Duration) *v9.BoolCmd) { - f.defaultHook = hook -} - -// PushHook adds a function to the end of hook queue. Each invocation of the -// SetXX method of the parent MockRedisClient instance invokes the hook at -// the front of the queue and discards it. After the queue is empty, the -// default hook function is invoked for any future action. -func (f *RedisClientSetXXFunc) PushHook(hook func(context.Context, string, interface{}, time.Duration) *v9.BoolCmd) { - f.mutex.Lock() - f.hooks = append(f.hooks, hook) - f.mutex.Unlock() -} - -// SetDefaultReturn calls SetDefaultHook with a function that returns the -// given values. -func (f *RedisClientSetXXFunc) SetDefaultReturn(r0 *v9.BoolCmd) { - f.SetDefaultHook(func(context.Context, string, interface{}, time.Duration) *v9.BoolCmd { - return r0 - }) -} - -// PushReturn calls PushHook with a function that returns the given values. -func (f *RedisClientSetXXFunc) PushReturn(r0 *v9.BoolCmd) { - f.PushHook(func(context.Context, string, interface{}, time.Duration) *v9.BoolCmd { - return r0 - }) -} - -func (f *RedisClientSetXXFunc) nextHook() func(context.Context, string, interface{}, time.Duration) *v9.BoolCmd { - f.mutex.Lock() - defer f.mutex.Unlock() - - if len(f.hooks) == 0 { - return f.defaultHook - } - - hook := f.hooks[0] - f.hooks = f.hooks[1:] - return hook -} - -func (f *RedisClientSetXXFunc) appendCall(r0 RedisClientSetXXFuncCall) { - f.mutex.Lock() - f.history = append(f.history, r0) - f.mutex.Unlock() -} - -// History returns a sequence of RedisClientSetXXFuncCall objects describing -// the invocations of this function. -func (f *RedisClientSetXXFunc) History() []RedisClientSetXXFuncCall { - f.mutex.Lock() - history := make([]RedisClientSetXXFuncCall, len(f.history)) - copy(history, f.history) - f.mutex.Unlock() - - return history -} - -// RedisClientSetXXFuncCall is an object that describes an invocation of -// method SetXX on an instance of MockRedisClient. -type RedisClientSetXXFuncCall struct { - // Arg0 is the value of the 1st argument passed to this method - // invocation. - Arg0 context.Context - // Arg1 is the value of the 2nd argument passed to this method - // invocation. - Arg1 string - // Arg2 is the value of the 3rd argument passed to this method - // invocation. - Arg2 interface{} - // Arg3 is the value of the 4th argument passed to this method - // invocation. - Arg3 time.Duration - // Result0 is the value of the 1st result returned from this method - // invocation. - Result0 *v9.BoolCmd -} - -// Args returns an interface slice containing the arguments of this -// invocation. -func (c RedisClientSetXXFuncCall) Args() []interface{} { - return []interface{}{c.Arg0, c.Arg1, c.Arg2, c.Arg3} -} - -// Results returns an interface slice containing the results of this -// invocation. -func (c RedisClientSetXXFuncCall) Results() []interface{} { - return []interface{}{c.Result0} -} - -// RedisClientSortFunc describes the behavior when the Sort method of the -// parent MockRedisClient instance is invoked. -type RedisClientSortFunc struct { - defaultHook func(context.Context, string, *v9.Sort) *v9.StringSliceCmd - hooks []func(context.Context, string, *v9.Sort) *v9.StringSliceCmd - history []RedisClientSortFuncCall - mutex sync.Mutex -} - -// Sort delegates to the next hook function in the queue and stores the -// parameter and result values of this invocation. -func (m *MockRedisClient) Sort(v0 context.Context, v1 string, v2 *v9.Sort) *v9.StringSliceCmd { - r0 := m.SortFunc.nextHook()(v0, v1, v2) - m.SortFunc.appendCall(RedisClientSortFuncCall{v0, v1, v2, r0}) - return r0 -} - -// SetDefaultHook sets function that is called when the Sort method of the -// parent MockRedisClient instance is invoked and the hook queue is empty. -func (f *RedisClientSortFunc) SetDefaultHook(hook func(context.Context, string, *v9.Sort) *v9.StringSliceCmd) { - f.defaultHook = hook -} - -// PushHook adds a function to the end of hook queue. Each invocation of the -// Sort method of the parent MockRedisClient instance invokes the hook at -// the front of the queue and discards it. After the queue is empty, the -// default hook function is invoked for any future action. -func (f *RedisClientSortFunc) PushHook(hook func(context.Context, string, *v9.Sort) *v9.StringSliceCmd) { - f.mutex.Lock() - f.hooks = append(f.hooks, hook) - f.mutex.Unlock() -} - -// SetDefaultReturn calls SetDefaultHook with a function that returns the -// given values. -func (f *RedisClientSortFunc) SetDefaultReturn(r0 *v9.StringSliceCmd) { - f.SetDefaultHook(func(context.Context, string, *v9.Sort) *v9.StringSliceCmd { - return r0 - }) -} - -// PushReturn calls PushHook with a function that returns the given values. -func (f *RedisClientSortFunc) PushReturn(r0 *v9.StringSliceCmd) { - f.PushHook(func(context.Context, string, *v9.Sort) *v9.StringSliceCmd { - return r0 - }) -} - -func (f *RedisClientSortFunc) nextHook() func(context.Context, string, *v9.Sort) *v9.StringSliceCmd { - f.mutex.Lock() - defer f.mutex.Unlock() - - if len(f.hooks) == 0 { - return f.defaultHook - } - - hook := f.hooks[0] - f.hooks = f.hooks[1:] - return hook -} - -func (f *RedisClientSortFunc) appendCall(r0 RedisClientSortFuncCall) { - f.mutex.Lock() - f.history = append(f.history, r0) - f.mutex.Unlock() -} - -// History returns a sequence of RedisClientSortFuncCall objects describing -// the invocations of this function. -func (f *RedisClientSortFunc) History() []RedisClientSortFuncCall { - f.mutex.Lock() - history := make([]RedisClientSortFuncCall, len(f.history)) - copy(history, f.history) - f.mutex.Unlock() - - return history -} - -// RedisClientSortFuncCall is an object that describes an invocation of -// method Sort on an instance of MockRedisClient. -type RedisClientSortFuncCall struct { - // Arg0 is the value of the 1st argument passed to this method - // invocation. - Arg0 context.Context - // Arg1 is the value of the 2nd argument passed to this method - // invocation. - Arg1 string - // Arg2 is the value of the 3rd argument passed to this method - // invocation. - Arg2 *v9.Sort - // Result0 is the value of the 1st result returned from this method - // invocation. - Result0 *v9.StringSliceCmd -} - -// Args returns an interface slice containing the arguments of this -// invocation. -func (c RedisClientSortFuncCall) Args() []interface{} { - return []interface{}{c.Arg0, c.Arg1, c.Arg2} -} - -// Results returns an interface slice containing the results of this -// invocation. -func (c RedisClientSortFuncCall) Results() []interface{} { - return []interface{}{c.Result0} -} - -// RedisClientSortInterfacesFunc describes the behavior when the -// SortInterfaces method of the parent MockRedisClient instance is invoked. -type RedisClientSortInterfacesFunc struct { - defaultHook func(context.Context, string, *v9.Sort) *v9.SliceCmd - hooks []func(context.Context, string, *v9.Sort) *v9.SliceCmd - history []RedisClientSortInterfacesFuncCall - mutex sync.Mutex -} - -// SortInterfaces delegates to the next hook function in the queue and -// stores the parameter and result values of this invocation. -func (m *MockRedisClient) SortInterfaces(v0 context.Context, v1 string, v2 *v9.Sort) *v9.SliceCmd { - r0 := m.SortInterfacesFunc.nextHook()(v0, v1, v2) - m.SortInterfacesFunc.appendCall(RedisClientSortInterfacesFuncCall{v0, v1, v2, r0}) - return r0 -} - -// SetDefaultHook sets function that is called when the SortInterfaces -// method of the parent MockRedisClient instance is invoked and the hook -// queue is empty. -func (f *RedisClientSortInterfacesFunc) SetDefaultHook(hook func(context.Context, string, *v9.Sort) *v9.SliceCmd) { - f.defaultHook = hook -} - -// PushHook adds a function to the end of hook queue. Each invocation of the -// SortInterfaces method of the parent MockRedisClient instance invokes the -// hook at the front of the queue and discards it. After the queue is empty, -// the default hook function is invoked for any future action. -func (f *RedisClientSortInterfacesFunc) PushHook(hook func(context.Context, string, *v9.Sort) *v9.SliceCmd) { - f.mutex.Lock() - f.hooks = append(f.hooks, hook) - f.mutex.Unlock() -} - -// SetDefaultReturn calls SetDefaultHook with a function that returns the -// given values. -func (f *RedisClientSortInterfacesFunc) SetDefaultReturn(r0 *v9.SliceCmd) { - f.SetDefaultHook(func(context.Context, string, *v9.Sort) *v9.SliceCmd { - return r0 - }) -} - -// PushReturn calls PushHook with a function that returns the given values. -func (f *RedisClientSortInterfacesFunc) PushReturn(r0 *v9.SliceCmd) { - f.PushHook(func(context.Context, string, *v9.Sort) *v9.SliceCmd { - return r0 - }) -} - -func (f *RedisClientSortInterfacesFunc) nextHook() func(context.Context, string, *v9.Sort) *v9.SliceCmd { - f.mutex.Lock() - defer f.mutex.Unlock() - - if len(f.hooks) == 0 { - return f.defaultHook - } - - hook := f.hooks[0] - f.hooks = f.hooks[1:] - return hook -} - -func (f *RedisClientSortInterfacesFunc) appendCall(r0 RedisClientSortInterfacesFuncCall) { - f.mutex.Lock() - f.history = append(f.history, r0) - f.mutex.Unlock() -} - -// History returns a sequence of RedisClientSortInterfacesFuncCall objects -// describing the invocations of this function. -func (f *RedisClientSortInterfacesFunc) History() []RedisClientSortInterfacesFuncCall { - f.mutex.Lock() - history := make([]RedisClientSortInterfacesFuncCall, len(f.history)) - copy(history, f.history) - f.mutex.Unlock() - - return history -} - -// RedisClientSortInterfacesFuncCall is an object that describes an -// invocation of method SortInterfaces on an instance of MockRedisClient. -type RedisClientSortInterfacesFuncCall struct { - // Arg0 is the value of the 1st argument passed to this method - // invocation. - Arg0 context.Context - // Arg1 is the value of the 2nd argument passed to this method - // invocation. - Arg1 string - // Arg2 is the value of the 3rd argument passed to this method - // invocation. - Arg2 *v9.Sort - // Result0 is the value of the 1st result returned from this method - // invocation. - Result0 *v9.SliceCmd -} - -// Args returns an interface slice containing the arguments of this -// invocation. -func (c RedisClientSortInterfacesFuncCall) Args() []interface{} { - return []interface{}{c.Arg0, c.Arg1, c.Arg2} -} - -// Results returns an interface slice containing the results of this -// invocation. -func (c RedisClientSortInterfacesFuncCall) Results() []interface{} { - return []interface{}{c.Result0} -} - -// RedisClientSortROFunc describes the behavior when the SortRO method of -// the parent MockRedisClient instance is invoked. -type RedisClientSortROFunc struct { - defaultHook func(context.Context, string, *v9.Sort) *v9.StringSliceCmd - hooks []func(context.Context, string, *v9.Sort) *v9.StringSliceCmd - history []RedisClientSortROFuncCall - mutex sync.Mutex -} - -// SortRO delegates to the next hook function in the queue and stores the -// parameter and result values of this invocation. -func (m *MockRedisClient) SortRO(v0 context.Context, v1 string, v2 *v9.Sort) *v9.StringSliceCmd { - r0 := m.SortROFunc.nextHook()(v0, v1, v2) - m.SortROFunc.appendCall(RedisClientSortROFuncCall{v0, v1, v2, r0}) - return r0 -} - -// SetDefaultHook sets function that is called when the SortRO method of the -// parent MockRedisClient instance is invoked and the hook queue is empty. -func (f *RedisClientSortROFunc) SetDefaultHook(hook func(context.Context, string, *v9.Sort) *v9.StringSliceCmd) { - f.defaultHook = hook -} - -// PushHook adds a function to the end of hook queue. Each invocation of the -// SortRO method of the parent MockRedisClient instance invokes the hook at -// the front of the queue and discards it. After the queue is empty, the -// default hook function is invoked for any future action. -func (f *RedisClientSortROFunc) PushHook(hook func(context.Context, string, *v9.Sort) *v9.StringSliceCmd) { - f.mutex.Lock() - f.hooks = append(f.hooks, hook) - f.mutex.Unlock() -} - -// SetDefaultReturn calls SetDefaultHook with a function that returns the -// given values. -func (f *RedisClientSortROFunc) SetDefaultReturn(r0 *v9.StringSliceCmd) { - f.SetDefaultHook(func(context.Context, string, *v9.Sort) *v9.StringSliceCmd { - return r0 - }) -} - -// PushReturn calls PushHook with a function that returns the given values. -func (f *RedisClientSortROFunc) PushReturn(r0 *v9.StringSliceCmd) { - f.PushHook(func(context.Context, string, *v9.Sort) *v9.StringSliceCmd { - return r0 - }) -} - -func (f *RedisClientSortROFunc) nextHook() func(context.Context, string, *v9.Sort) *v9.StringSliceCmd { - f.mutex.Lock() - defer f.mutex.Unlock() - - if len(f.hooks) == 0 { - return f.defaultHook - } - - hook := f.hooks[0] - f.hooks = f.hooks[1:] - return hook -} - -func (f *RedisClientSortROFunc) appendCall(r0 RedisClientSortROFuncCall) { - f.mutex.Lock() - f.history = append(f.history, r0) - f.mutex.Unlock() -} - -// History returns a sequence of RedisClientSortROFuncCall objects -// describing the invocations of this function. -func (f *RedisClientSortROFunc) History() []RedisClientSortROFuncCall { - f.mutex.Lock() - history := make([]RedisClientSortROFuncCall, len(f.history)) - copy(history, f.history) - f.mutex.Unlock() - - return history -} - -// RedisClientSortROFuncCall is an object that describes an invocation of -// method SortRO on an instance of MockRedisClient. -type RedisClientSortROFuncCall struct { - // Arg0 is the value of the 1st argument passed to this method - // invocation. - Arg0 context.Context - // Arg1 is the value of the 2nd argument passed to this method - // invocation. - Arg1 string - // Arg2 is the value of the 3rd argument passed to this method - // invocation. - Arg2 *v9.Sort - // Result0 is the value of the 1st result returned from this method - // invocation. - Result0 *v9.StringSliceCmd -} - -// Args returns an interface slice containing the arguments of this -// invocation. -func (c RedisClientSortROFuncCall) Args() []interface{} { - return []interface{}{c.Arg0, c.Arg1, c.Arg2} -} - -// Results returns an interface slice containing the results of this -// invocation. -func (c RedisClientSortROFuncCall) Results() []interface{} { - return []interface{}{c.Result0} -} - -// RedisClientSortStoreFunc describes the behavior when the SortStore method -// of the parent MockRedisClient instance is invoked. -type RedisClientSortStoreFunc struct { - defaultHook func(context.Context, string, string, *v9.Sort) *v9.IntCmd - hooks []func(context.Context, string, string, *v9.Sort) *v9.IntCmd - history []RedisClientSortStoreFuncCall - mutex sync.Mutex -} - -// SortStore delegates to the next hook function in the queue and stores the -// parameter and result values of this invocation. -func (m *MockRedisClient) SortStore(v0 context.Context, v1 string, v2 string, v3 *v9.Sort) *v9.IntCmd { - r0 := m.SortStoreFunc.nextHook()(v0, v1, v2, v3) - m.SortStoreFunc.appendCall(RedisClientSortStoreFuncCall{v0, v1, v2, v3, r0}) - return r0 -} - -// SetDefaultHook sets function that is called when the SortStore method of -// the parent MockRedisClient instance is invoked and the hook queue is -// empty. -func (f *RedisClientSortStoreFunc) SetDefaultHook(hook func(context.Context, string, string, *v9.Sort) *v9.IntCmd) { - f.defaultHook = hook -} - -// PushHook adds a function to the end of hook queue. Each invocation of the -// SortStore method of the parent MockRedisClient instance invokes the hook -// at the front of the queue and discards it. After the queue is empty, the -// default hook function is invoked for any future action. -func (f *RedisClientSortStoreFunc) PushHook(hook func(context.Context, string, string, *v9.Sort) *v9.IntCmd) { - f.mutex.Lock() - f.hooks = append(f.hooks, hook) - f.mutex.Unlock() -} - -// SetDefaultReturn calls SetDefaultHook with a function that returns the -// given values. -func (f *RedisClientSortStoreFunc) SetDefaultReturn(r0 *v9.IntCmd) { - f.SetDefaultHook(func(context.Context, string, string, *v9.Sort) *v9.IntCmd { - return r0 - }) -} - -// PushReturn calls PushHook with a function that returns the given values. -func (f *RedisClientSortStoreFunc) PushReturn(r0 *v9.IntCmd) { - f.PushHook(func(context.Context, string, string, *v9.Sort) *v9.IntCmd { - return r0 - }) -} - -func (f *RedisClientSortStoreFunc) nextHook() func(context.Context, string, string, *v9.Sort) *v9.IntCmd { - f.mutex.Lock() - defer f.mutex.Unlock() - - if len(f.hooks) == 0 { - return f.defaultHook - } - - hook := f.hooks[0] - f.hooks = f.hooks[1:] - return hook -} - -func (f *RedisClientSortStoreFunc) appendCall(r0 RedisClientSortStoreFuncCall) { - f.mutex.Lock() - f.history = append(f.history, r0) - f.mutex.Unlock() -} - -// History returns a sequence of RedisClientSortStoreFuncCall objects -// describing the invocations of this function. -func (f *RedisClientSortStoreFunc) History() []RedisClientSortStoreFuncCall { - f.mutex.Lock() - history := make([]RedisClientSortStoreFuncCall, len(f.history)) - copy(history, f.history) - f.mutex.Unlock() - - return history -} - -// RedisClientSortStoreFuncCall is an object that describes an invocation of -// method SortStore on an instance of MockRedisClient. -type RedisClientSortStoreFuncCall struct { - // Arg0 is the value of the 1st argument passed to this method - // invocation. - Arg0 context.Context - // Arg1 is the value of the 2nd argument passed to this method - // invocation. - Arg1 string - // Arg2 is the value of the 3rd argument passed to this method - // invocation. - Arg2 string - // Arg3 is the value of the 4th argument passed to this method - // invocation. - Arg3 *v9.Sort - // Result0 is the value of the 1st result returned from this method - // invocation. - Result0 *v9.IntCmd -} - -// Args returns an interface slice containing the arguments of this -// invocation. -func (c RedisClientSortStoreFuncCall) Args() []interface{} { - return []interface{}{c.Arg0, c.Arg1, c.Arg2, c.Arg3} -} - -// Results returns an interface slice containing the results of this -// invocation. -func (c RedisClientSortStoreFuncCall) Results() []interface{} { - return []interface{}{c.Result0} -} - -// RedisClientStrLenFunc describes the behavior when the StrLen method of -// the parent MockRedisClient instance is invoked. -type RedisClientStrLenFunc struct { - defaultHook func(context.Context, string) *v9.IntCmd - hooks []func(context.Context, string) *v9.IntCmd - history []RedisClientStrLenFuncCall - mutex sync.Mutex -} - -// StrLen delegates to the next hook function in the queue and stores the -// parameter and result values of this invocation. -func (m *MockRedisClient) StrLen(v0 context.Context, v1 string) *v9.IntCmd { - r0 := m.StrLenFunc.nextHook()(v0, v1) - m.StrLenFunc.appendCall(RedisClientStrLenFuncCall{v0, v1, r0}) - return r0 -} - -// SetDefaultHook sets function that is called when the StrLen method of the -// parent MockRedisClient instance is invoked and the hook queue is empty. -func (f *RedisClientStrLenFunc) SetDefaultHook(hook func(context.Context, string) *v9.IntCmd) { - f.defaultHook = hook -} - -// PushHook adds a function to the end of hook queue. Each invocation of the -// StrLen method of the parent MockRedisClient instance invokes the hook at -// the front of the queue and discards it. After the queue is empty, the -// default hook function is invoked for any future action. -func (f *RedisClientStrLenFunc) PushHook(hook func(context.Context, string) *v9.IntCmd) { - f.mutex.Lock() - f.hooks = append(f.hooks, hook) - f.mutex.Unlock() -} - -// SetDefaultReturn calls SetDefaultHook with a function that returns the -// given values. -func (f *RedisClientStrLenFunc) SetDefaultReturn(r0 *v9.IntCmd) { - f.SetDefaultHook(func(context.Context, string) *v9.IntCmd { - return r0 - }) -} - -// PushReturn calls PushHook with a function that returns the given values. -func (f *RedisClientStrLenFunc) PushReturn(r0 *v9.IntCmd) { - f.PushHook(func(context.Context, string) *v9.IntCmd { - return r0 - }) -} - -func (f *RedisClientStrLenFunc) nextHook() func(context.Context, string) *v9.IntCmd { - f.mutex.Lock() - defer f.mutex.Unlock() - - if len(f.hooks) == 0 { - return f.defaultHook - } - - hook := f.hooks[0] - f.hooks = f.hooks[1:] - return hook -} - -func (f *RedisClientStrLenFunc) appendCall(r0 RedisClientStrLenFuncCall) { - f.mutex.Lock() - f.history = append(f.history, r0) - f.mutex.Unlock() -} - -// History returns a sequence of RedisClientStrLenFuncCall objects -// describing the invocations of this function. -func (f *RedisClientStrLenFunc) History() []RedisClientStrLenFuncCall { - f.mutex.Lock() - history := make([]RedisClientStrLenFuncCall, len(f.history)) - copy(history, f.history) - f.mutex.Unlock() - - return history -} - -// RedisClientStrLenFuncCall is an object that describes an invocation of -// method StrLen on an instance of MockRedisClient. -type RedisClientStrLenFuncCall struct { - // Arg0 is the value of the 1st argument passed to this method - // invocation. - Arg0 context.Context - // Arg1 is the value of the 2nd argument passed to this method - // invocation. - Arg1 string - // Result0 is the value of the 1st result returned from this method - // invocation. - Result0 *v9.IntCmd -} - -// Args returns an interface slice containing the arguments of this -// invocation. -func (c RedisClientStrLenFuncCall) Args() []interface{} { - return []interface{}{c.Arg0, c.Arg1} -} - -// Results returns an interface slice containing the results of this -// invocation. -func (c RedisClientStrLenFuncCall) Results() []interface{} { - return []interface{}{c.Result0} -} - -// RedisClientTTLFunc describes the behavior when the TTL method of the -// parent MockRedisClient instance is invoked. -type RedisClientTTLFunc struct { - defaultHook func(context.Context, string) *v9.DurationCmd - hooks []func(context.Context, string) *v9.DurationCmd - history []RedisClientTTLFuncCall - mutex sync.Mutex -} - -// TTL delegates to the next hook function in the queue and stores the -// parameter and result values of this invocation. -func (m *MockRedisClient) TTL(v0 context.Context, v1 string) *v9.DurationCmd { - r0 := m.TTLFunc.nextHook()(v0, v1) - m.TTLFunc.appendCall(RedisClientTTLFuncCall{v0, v1, r0}) - return r0 -} - -// SetDefaultHook sets function that is called when the TTL method of the -// parent MockRedisClient instance is invoked and the hook queue is empty. -func (f *RedisClientTTLFunc) SetDefaultHook(hook func(context.Context, string) *v9.DurationCmd) { - f.defaultHook = hook -} - -// PushHook adds a function to the end of hook queue. Each invocation of the -// TTL method of the parent MockRedisClient instance invokes the hook at the -// front of the queue and discards it. After the queue is empty, the default -// hook function is invoked for any future action. -func (f *RedisClientTTLFunc) PushHook(hook func(context.Context, string) *v9.DurationCmd) { - f.mutex.Lock() - f.hooks = append(f.hooks, hook) - f.mutex.Unlock() -} - -// SetDefaultReturn calls SetDefaultHook with a function that returns the -// given values. -func (f *RedisClientTTLFunc) SetDefaultReturn(r0 *v9.DurationCmd) { - f.SetDefaultHook(func(context.Context, string) *v9.DurationCmd { - return r0 - }) -} - -// PushReturn calls PushHook with a function that returns the given values. -func (f *RedisClientTTLFunc) PushReturn(r0 *v9.DurationCmd) { - f.PushHook(func(context.Context, string) *v9.DurationCmd { - return r0 - }) -} - -func (f *RedisClientTTLFunc) nextHook() func(context.Context, string) *v9.DurationCmd { - f.mutex.Lock() - defer f.mutex.Unlock() - - if len(f.hooks) == 0 { - return f.defaultHook - } - - hook := f.hooks[0] - f.hooks = f.hooks[1:] - return hook -} - -func (f *RedisClientTTLFunc) appendCall(r0 RedisClientTTLFuncCall) { - f.mutex.Lock() - f.history = append(f.history, r0) - f.mutex.Unlock() -} - -// History returns a sequence of RedisClientTTLFuncCall objects describing -// the invocations of this function. -func (f *RedisClientTTLFunc) History() []RedisClientTTLFuncCall { - f.mutex.Lock() - history := make([]RedisClientTTLFuncCall, len(f.history)) - copy(history, f.history) - f.mutex.Unlock() - - return history -} - -// RedisClientTTLFuncCall is an object that describes an invocation of -// method TTL on an instance of MockRedisClient. -type RedisClientTTLFuncCall struct { - // Arg0 is the value of the 1st argument passed to this method - // invocation. - Arg0 context.Context - // Arg1 is the value of the 2nd argument passed to this method - // invocation. - Arg1 string - // Result0 is the value of the 1st result returned from this method - // invocation. - Result0 *v9.DurationCmd -} - -// Args returns an interface slice containing the arguments of this -// invocation. -func (c RedisClientTTLFuncCall) Args() []interface{} { - return []interface{}{c.Arg0, c.Arg1} -} - -// Results returns an interface slice containing the results of this -// invocation. -func (c RedisClientTTLFuncCall) Results() []interface{} { - return []interface{}{c.Result0} -} - -// RedisClientTouchFunc describes the behavior when the Touch method of the -// parent MockRedisClient instance is invoked. -type RedisClientTouchFunc struct { - defaultHook func(context.Context, ...string) *v9.IntCmd - hooks []func(context.Context, ...string) *v9.IntCmd - history []RedisClientTouchFuncCall - mutex sync.Mutex -} - -// Touch delegates to the next hook function in the queue and stores the -// parameter and result values of this invocation. -func (m *MockRedisClient) Touch(v0 context.Context, v1 ...string) *v9.IntCmd { - r0 := m.TouchFunc.nextHook()(v0, v1...) - m.TouchFunc.appendCall(RedisClientTouchFuncCall{v0, v1, r0}) - return r0 -} - -// SetDefaultHook sets function that is called when the Touch method of the -// parent MockRedisClient instance is invoked and the hook queue is empty. -func (f *RedisClientTouchFunc) SetDefaultHook(hook func(context.Context, ...string) *v9.IntCmd) { - f.defaultHook = hook -} - -// PushHook adds a function to the end of hook queue. Each invocation of the -// Touch method of the parent MockRedisClient instance invokes the hook at -// the front of the queue and discards it. After the queue is empty, the -// default hook function is invoked for any future action. -func (f *RedisClientTouchFunc) PushHook(hook func(context.Context, ...string) *v9.IntCmd) { - f.mutex.Lock() - f.hooks = append(f.hooks, hook) - f.mutex.Unlock() -} - -// SetDefaultReturn calls SetDefaultHook with a function that returns the -// given values. -func (f *RedisClientTouchFunc) SetDefaultReturn(r0 *v9.IntCmd) { - f.SetDefaultHook(func(context.Context, ...string) *v9.IntCmd { - return r0 - }) -} - -// PushReturn calls PushHook with a function that returns the given values. -func (f *RedisClientTouchFunc) PushReturn(r0 *v9.IntCmd) { - f.PushHook(func(context.Context, ...string) *v9.IntCmd { - return r0 - }) -} - -func (f *RedisClientTouchFunc) nextHook() func(context.Context, ...string) *v9.IntCmd { - f.mutex.Lock() - defer f.mutex.Unlock() - - if len(f.hooks) == 0 { - return f.defaultHook - } - - hook := f.hooks[0] - f.hooks = f.hooks[1:] - return hook -} - -func (f *RedisClientTouchFunc) appendCall(r0 RedisClientTouchFuncCall) { - f.mutex.Lock() - f.history = append(f.history, r0) - f.mutex.Unlock() -} - -// History returns a sequence of RedisClientTouchFuncCall objects describing -// the invocations of this function. -func (f *RedisClientTouchFunc) History() []RedisClientTouchFuncCall { - f.mutex.Lock() - history := make([]RedisClientTouchFuncCall, len(f.history)) - copy(history, f.history) - f.mutex.Unlock() - - return history -} - -// RedisClientTouchFuncCall is an object that describes an invocation of -// method Touch on an instance of MockRedisClient. -type RedisClientTouchFuncCall struct { - // Arg0 is the value of the 1st argument passed to this method - // invocation. - Arg0 context.Context - // Arg1 is a slice containing the values of the variadic arguments - // passed to this method invocation. - Arg1 []string - // Result0 is the value of the 1st result returned from this method - // invocation. - Result0 *v9.IntCmd -} - -// Args returns an interface slice containing the arguments of this -// invocation. The variadic slice argument is flattened in this array such -// that one positional argument and three variadic arguments would result in -// a slice of four, not two. -func (c RedisClientTouchFuncCall) Args() []interface{} { - trailing := []interface{}{} - for _, val := range c.Arg1 { - trailing = append(trailing, val) - } - - return append([]interface{}{c.Arg0}, trailing...) -} - -// Results returns an interface slice containing the results of this -// invocation. -func (c RedisClientTouchFuncCall) Results() []interface{} { - return []interface{}{c.Result0} -} - -// RedisClientTypeFunc describes the behavior when the Type method of the -// parent MockRedisClient instance is invoked. -type RedisClientTypeFunc struct { - defaultHook func(context.Context, string) *v9.StatusCmd - hooks []func(context.Context, string) *v9.StatusCmd - history []RedisClientTypeFuncCall - mutex sync.Mutex -} - -// Type delegates to the next hook function in the queue and stores the -// parameter and result values of this invocation. -func (m *MockRedisClient) Type(v0 context.Context, v1 string) *v9.StatusCmd { - r0 := m.TypeFunc.nextHook()(v0, v1) - m.TypeFunc.appendCall(RedisClientTypeFuncCall{v0, v1, r0}) - return r0 -} - -// SetDefaultHook sets function that is called when the Type method of the -// parent MockRedisClient instance is invoked and the hook queue is empty. -func (f *RedisClientTypeFunc) SetDefaultHook(hook func(context.Context, string) *v9.StatusCmd) { - f.defaultHook = hook -} - -// PushHook adds a function to the end of hook queue. Each invocation of the -// Type method of the parent MockRedisClient instance invokes the hook at -// the front of the queue and discards it. After the queue is empty, the -// default hook function is invoked for any future action. -func (f *RedisClientTypeFunc) PushHook(hook func(context.Context, string) *v9.StatusCmd) { - f.mutex.Lock() - f.hooks = append(f.hooks, hook) - f.mutex.Unlock() -} - -// SetDefaultReturn calls SetDefaultHook with a function that returns the -// given values. -func (f *RedisClientTypeFunc) SetDefaultReturn(r0 *v9.StatusCmd) { - f.SetDefaultHook(func(context.Context, string) *v9.StatusCmd { - return r0 - }) -} - -// PushReturn calls PushHook with a function that returns the given values. -func (f *RedisClientTypeFunc) PushReturn(r0 *v9.StatusCmd) { - f.PushHook(func(context.Context, string) *v9.StatusCmd { - return r0 - }) -} - -func (f *RedisClientTypeFunc) nextHook() func(context.Context, string) *v9.StatusCmd { - f.mutex.Lock() - defer f.mutex.Unlock() - - if len(f.hooks) == 0 { - return f.defaultHook - } - - hook := f.hooks[0] - f.hooks = f.hooks[1:] - return hook -} - -func (f *RedisClientTypeFunc) appendCall(r0 RedisClientTypeFuncCall) { - f.mutex.Lock() - f.history = append(f.history, r0) - f.mutex.Unlock() -} - -// History returns a sequence of RedisClientTypeFuncCall objects describing -// the invocations of this function. -func (f *RedisClientTypeFunc) History() []RedisClientTypeFuncCall { - f.mutex.Lock() - history := make([]RedisClientTypeFuncCall, len(f.history)) - copy(history, f.history) - f.mutex.Unlock() - - return history -} - -// RedisClientTypeFuncCall is an object that describes an invocation of -// method Type on an instance of MockRedisClient. -type RedisClientTypeFuncCall struct { - // Arg0 is the value of the 1st argument passed to this method - // invocation. - Arg0 context.Context - // Arg1 is the value of the 2nd argument passed to this method - // invocation. - Arg1 string - // Result0 is the value of the 1st result returned from this method - // invocation. - Result0 *v9.StatusCmd -} - -// Args returns an interface slice containing the arguments of this -// invocation. -func (c RedisClientTypeFuncCall) Args() []interface{} { - return []interface{}{c.Arg0, c.Arg1} -} - -// Results returns an interface slice containing the results of this -// invocation. -func (c RedisClientTypeFuncCall) Results() []interface{} { - return []interface{}{c.Result0} -} diff --git a/dev/build-tracker/integration_test.go b/dev/build-tracker/integration_test.go index dab72337a94..c85c2309e2b 100644 --- a/dev/build-tracker/integration_test.go +++ b/dev/build-tracker/integration_test.go @@ -436,7 +436,7 @@ func TestServerNotify(t *testing.T) { SlackChannel: os.Getenv("SLACK_CHANNEL"), } - server := NewServer(":8080", logger, conf, nil, nil, nil) + server := NewServer(":8080", logger, conf, nil) num := 160000 url := "http://www.google.com" diff --git a/dev/build-tracker/main.go b/dev/build-tracker/main.go index 546d084a2c4..a54bdb3f09e 100644 --- a/dev/build-tracker/main.go +++ b/dev/build-tracker/main.go @@ -11,10 +11,7 @@ import ( "time" "github.com/buildkite/go-buildkite/v3/buildkite" - "github.com/go-redsync/redsync/v4" - "github.com/go-redsync/redsync/v4/redis/goredis/v9" "github.com/gorilla/mux" - "github.com/redis/go-redis/v9" "golang.org/x/exp/maps" "github.com/sourcegraph/log" @@ -50,7 +47,7 @@ type Server struct { } // NewServer creatse a new server to listen for Buildkite webhook events. -func NewServer(addr string, logger log.Logger, c config.Config, bqWriter BigQueryWriter, rclient build.RedisClient, rlock build.Locker) *Server { +func NewServer(addr string, logger log.Logger, c config.Config, bqWriter BigQueryWriter) *Server { logger = logger.Scoped("server") if testutil.IsTest && c.BuildkiteToken == "" { @@ -65,7 +62,7 @@ func NewServer(addr string, logger log.Logger, c config.Config, bqWriter BigQuer server := &Server{ logger: logger, - store: build.NewBuildStore(logger, rclient, rlock), + store: build.NewBuildStore(logger), config: &c, notifyClient: notify.NewClient(logger, c.SlackToken, c.SlackChannel), bqWriter: bqWriter, @@ -108,9 +105,6 @@ func (s *Server) Stop(ctx context.Context) error { } func (s *Server) handleGetBuild(w http.ResponseWriter, req *http.Request) { - ctx, cancel := context.WithTimeout(req.Context(), time.Second*30) - defer cancel() - if s.config.Production { user, pass, ok := req.BasicAuth() if !ok { @@ -143,7 +137,7 @@ func (s *Server) handleGetBuild(w http.ResponseWriter, req *http.Request) { } s.logger.Info("retrieving build", log.Int("buildNumber", buildNum)) - build := s.store.GetByBuildNumber(ctx, buildNum) + build := s.store.GetByBuildNumber(buildNum) if build == nil { s.logger.Debug("no build found", log.Int("buildNumber", buildNum)) w.WriteHeader(http.StatusNotFound) @@ -164,9 +158,6 @@ func (s *Server) handleGetBuild(w http.ResponseWriter, req *http.Request) { // Note that if we received an unwanted event ie. the event is not "job.finished" or "build.finished" we respond with a 200 OK regardless. // Once all the conditions are met, the event is processed in a go routine with `processEvent` func (s *Server) handleEvent(w http.ResponseWriter, req *http.Request) { - ctx, cancel := context.WithTimeout(req.Context(), time.Second*30) - defer cancel() - h, ok := req.Header["X-Buildkite-Token"] if !ok || len(h) == 0 { w.WriteHeader(http.StatusBadRequest) @@ -202,9 +193,9 @@ func (s *Server) handleEvent(w http.ResponseWriter, req *http.Request) { } if testutil.IsTest { - s.processEvent(ctx, &event) + s.processEvent(&event) } else { - go s.processEvent(ctx, &event) + go s.processEvent(&event) } w.WriteHeader(http.StatusOK) } @@ -230,6 +221,10 @@ func (s *Server) notifyIfFailed(b *build.Build) error { if info.BuildStatus == string(build.BuildFailed) || info.BuildStatus == string(build.BuildFixed) { s.logger.Info("sending notification for build", log.Int("buildNumber", b.GetNumber()), log.String("status", string(info.BuildStatus))) + // We lock the build while we send a notification so that we can ensure any late jobs do not interfere with what + // we're about to send. + b.Lock() + defer b.Unlock() err := s.notifyClient.Send(info) return err } @@ -300,11 +295,11 @@ func (s *Server) triggerMetricsPipeline(b *build.Build) error { // processEvent processes a BuildEvent received from Buildkite. If the event is for a `build.finished` event we get the // full build which includes all recorded jobs for the build and send a notification. // processEvent delegates the decision to actually send a notifcation -func (s *Server) processEvent(ctx context.Context, event *build.Event) { +func (s *Server) processEvent(event *build.Event) { if event.Build.Number != nil { s.logger.Info("processing event", log.String("eventName", event.Name), log.Int("buildNumber", event.GetBuildNumber()), log.String("jobName", event.GetJobName())) - s.store.Add(ctx, event) - b := s.store.GetByBuildNumber(ctx, event.GetBuildNumber()) + s.store.Add(event) + b := s.store.GetByBuildNumber(event.GetBuildNumber()) if event.IsBuildFinished() { if *event.Build.Branch == "main" { if err := s.notifyIfFailed(b); err != nil { @@ -428,14 +423,7 @@ func (s Service) Initialize(ctx context.Context, logger log.Logger, contract run return nil, err } - redisOpts, err := redis.ParseURL(*contract.RedisEndpoint) - if err != nil { - return nil, err - } - rclient := redis.NewClient(redisOpts) - rlock := redsync.New(goredis.NewPool(rclient)).NewMutex("build-tracker", redsync.WithExpiry(time.Second*30)) - - server := NewServer(fmt.Sprintf(":%d", contract.Port), logger, config, bqWriter, rclient, rlock) + server := NewServer(fmt.Sprintf(":%d", contract.Port), logger, config, bqWriter) return background.CombinedRoutine{ server, diff --git a/dev/build-tracker/server_test.go b/dev/build-tracker/server_test.go index de4075594b7..05094974e52 100644 --- a/dev/build-tracker/server_test.go +++ b/dev/build-tracker/server_test.go @@ -12,7 +12,6 @@ import ( "cloud.google.com/go/bigquery" "github.com/buildkite/go-buildkite/v3/buildkite" "github.com/gorilla/mux" - "github.com/redis/go-redis/v9" "github.com/sourcegraph/log/logtest" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" @@ -30,7 +29,7 @@ func TestGetBuild(t *testing.T) { req, _ := http.NewRequest(http.MethodGet, "/-/debug/1234", nil) req = mux.SetURLVars(req, map[string]string{"buildNumber": "1234"}) t.Run("401 Unauthorized when in production mode and incorrect credentials", func(t *testing.T) { - server := NewServer(":8080", logger, config.Config{Production: true, DebugPassword: "this is a test"}, nil, nil, nil) + server := NewServer(":8080", logger, config.Config{Production: true, DebugPassword: "this is a test"}, nil) rec := httptest.NewRecorder() server.handleGetBuild(rec, req) @@ -43,7 +42,7 @@ func TestGetBuild(t *testing.T) { }) t.Run("404 for build that does not exist", func(t *testing.T) { - server := NewServer(":8080", logger, config.Config{}, nil, mockRedisClient(), build.NewMockLocker()) + server := NewServer(":8080", logger, config.Config{}, nil) rec := httptest.NewRecorder() server.handleGetBuild(rec, req) @@ -51,7 +50,7 @@ func TestGetBuild(t *testing.T) { }) t.Run("get marshalled json for build", func(t *testing.T) { - server := NewServer(":8080", logger, config.Config{}, nil, mockRedisClient(), build.NewMockLocker()) + server := NewServer(":8080", logger, config.Config{}, nil) rec := httptest.NewRecorder() num := 1234 @@ -91,7 +90,7 @@ func TestGetBuild(t *testing.T) { expected := event.WrappedBuild() expected.AddJob(event.WrappedJob()) - server.store.Add(context.Background(), &event) + server.store.Add(&event) server.handleGetBuild(rec, req) @@ -104,14 +103,12 @@ func TestGetBuild(t *testing.T) { }) t.Run("200 with valid credentials in production mode", func(t *testing.T) { - rclient := build.NewMockRedisClient() - rclient.GetFunc.SetDefaultReturn(redis.NewStringResult("", redis.Nil)) - server := NewServer(":8080", logger, config.Config{Production: true, DebugPassword: "this is a test"}, nil, rclient, build.NewMockLocker()) + server := NewServer(":8080", logger, config.Config{Production: true, DebugPassword: "this is a test"}, nil) rec := httptest.NewRecorder() req.SetBasicAuth("devx", server.config.DebugPassword) num := 1234 - server.store.Add(context.Background(), &build.Event{ + server.store.Add(&build.Event{ Name: "Fake", Build: buildkite.Build{ Number: &num, @@ -119,7 +116,6 @@ func TestGetBuild(t *testing.T) { Pipeline: buildkite.Pipeline{}, Job: buildkite.Job{}, }) - rclient.GetFunc.PushReturn(redis.NewStringResult("{}", nil)) server.handleGetBuild(rec, req) require.Equal(t, http.StatusOK, rec.Result().StatusCode) @@ -139,15 +135,15 @@ func TestOldBuildsGetDeleted(t *testing.T) { } t.Run("All old builds get removed", func(t *testing.T) { - server := NewServer(":8080", logger, config.Config{}, nil, mockRedisClient(), build.NewMockLocker()) + server := NewServer(":8080", logger, config.Config{}, nil) b := finishedBuild(1, "passed", time.Now().AddDate(-1, 0, 0)) - server.store.Set(context.Background(), b) + server.store.Set(b) b = finishedBuild(2, "canceled", time.Now().AddDate(0, -1, 0)) - server.store.Set(context.Background(), b) + server.store.Set(b) b = finishedBuild(3, "failed", time.Now().AddDate(0, 0, -1)) - server.store.Set(context.Background(), b) + server.store.Set(b) ctx, cancel := context.WithCancel(context.Background()) go func() { @@ -160,22 +156,22 @@ func TestOldBuildsGetDeleted(t *testing.T) { time.Sleep(20 * time.Millisecond) cancel() - builds := server.store.FinishedBuilds(context.Background()) + builds := server.store.FinishedBuilds() if len(builds) != 0 { t.Errorf("Not all old builds removed. Got %d, wanted %d", len(builds), 0) } }) t.Run("1 build left after old builds are removed", func(t *testing.T) { - server := NewServer(":8080", logger, config.Config{}, nil, mockRedisClient(), build.NewMockLocker()) + server := NewServer(":8080", logger, config.Config{}, nil) b := finishedBuild(1, "canceled", time.Now().AddDate(-1, 0, 0)) - server.store.Set(context.Background(), b) + server.store.Set(b) b = finishedBuild(2, "passed", time.Now().AddDate(0, -1, 0)) - server.store.Set(context.Background(), b) + server.store.Set(b) b = finishedBuild(3, "failed", time.Now()) - server.store.Set(context.Background(), b) + server.store.Set(b) ctx, cancel := context.WithCancel(context.Background()) go func() { @@ -188,7 +184,7 @@ func TestOldBuildsGetDeleted(t *testing.T) { time.Sleep(20 * time.Millisecond) cancel() - builds := server.store.FinishedBuilds(context.Background()) + builds := server.store.FinishedBuilds() if len(builds) != 1 { t.Errorf("Expected one build to be left over. Got %d, wanted %d", len(builds), 1) @@ -256,75 +252,74 @@ func TestProcessEvent(t *testing.T) { return &build.Event{Name: build.EventBuildFinished, Build: buildkite.Build{State: &state, Branch: &branch, Number: &buildNumber, Pipeline: pipeline}, Job: job.Job, Pipeline: *pipeline} } t.Run("no send notification on unfinished builds", func(t *testing.T) { - server := NewServer(":8080", logger, config.Config{}, nil, mockRedisClient(), build.NewMockLocker()) - + server := NewServer(":8080", logger, config.Config{}, nil) mockNotifyClient := &MockNotificationClient{} server.notifyClient = mockNotifyClient buildNumber := 1234 buildStartedEvent := newBuildEvent("test 2", buildNumber, "failed", "main", 1) buildStartedEvent.Name = "build.started" - server.processEvent(context.Background(), buildStartedEvent) + server.processEvent(buildStartedEvent) require.Equal(t, 0, mockNotifyClient.sendCalled) - server.processEvent(context.Background(), newJobEvent("test", buildNumber, 0)) + server.processEvent(newJobEvent("test", buildNumber, 0)) // build is not finished so we should send nothing require.Equal(t, 0, mockNotifyClient.sendCalled) - builds := server.store.FinishedBuilds(context.Background()) + builds := server.store.FinishedBuilds() require.Equal(t, 1, len(builds)) }) t.Run("failed build sends notification", func(t *testing.T) { - server := NewServer(":8080", logger, config.Config{}, nil, mockRedisClient(), build.NewMockLocker()) + server := NewServer(":8080", logger, config.Config{}, nil) mockNotifyClient := &MockNotificationClient{} server.notifyClient = mockNotifyClient buildNumber := 1234 - server.processEvent(context.Background(), newJobEvent("test", buildNumber, 0)) - server.processEvent(context.Background(), newBuildEvent("test 2", buildNumber, "failed", "main", 1)) + server.processEvent(newJobEvent("test", buildNumber, 0)) + server.processEvent(newBuildEvent("test 2", buildNumber, "failed", "main", 1)) require.Equal(t, 1, mockNotifyClient.sendCalled) - builds := server.store.FinishedBuilds(context.Background()) + builds := server.store.FinishedBuilds() require.Equal(t, 1, len(builds)) require.Equal(t, 1234, *builds[0].Number) require.Equal(t, "failed", *builds[0].State) }) t.Run("passed build sends notification", func(t *testing.T) { - server := NewServer(":8080", logger, config.Config{}, nil, mockRedisClient(), build.NewMockLocker()) + server := NewServer(":8080", logger, config.Config{}, nil) mockNotifyClient := &MockNotificationClient{} server.notifyClient = mockNotifyClient buildNumber := 1234 - server.processEvent(context.Background(), newJobEvent("test", buildNumber, 0)) - server.processEvent(context.Background(), newBuildEvent("test 2", buildNumber, "passed", "main", 0)) + server.processEvent(newJobEvent("test", buildNumber, 0)) + server.processEvent(newBuildEvent("test 2", buildNumber, "passed", "main", 0)) require.Equal(t, 0, mockNotifyClient.sendCalled) - builds := server.store.FinishedBuilds(context.Background()) + builds := server.store.FinishedBuilds() require.Equal(t, 1, len(builds)) require.Equal(t, 1234, *builds[0].Number) require.Equal(t, "passed", *builds[0].State) }) t.Run("failed build, then passed build sends fixed notification", func(t *testing.T) { - server := NewServer(":8080", logger, config.Config{}, nil, mockRedisClient(), build.NewMockLocker()) + server := NewServer(":8080", logger, config.Config{}, nil) mockNotifyClient := &MockNotificationClient{} server.notifyClient = mockNotifyClient buildNumber := 1234 - server.processEvent(context.Background(), newJobEvent("test 1", buildNumber, 1)) - server.processEvent(context.Background(), newBuildEvent("test 2", buildNumber, "failed", "main", 1)) + server.processEvent(newJobEvent("test 1", buildNumber, 1)) + server.processEvent(newBuildEvent("test 2", buildNumber, "failed", "main", 1)) require.Equal(t, 1, mockNotifyClient.sendCalled) - builds := server.store.FinishedBuilds(context.Background()) + builds := server.store.FinishedBuilds() require.Equal(t, 1, len(builds)) require.Equal(t, 1234, *builds[0].Number) require.Equal(t, "failed", *builds[0].State) - server.processEvent(context.Background(), newJobEvent("test 1", buildNumber, 0)) - server.processEvent(context.Background(), newBuildEvent("test 2", buildNumber, "passed", "main", 0)) + server.processEvent(newJobEvent("test 1", buildNumber, 0)) + server.processEvent(newBuildEvent("test 2", buildNumber, "passed", "main", 0)) - builds = server.store.FinishedBuilds(context.Background()) + builds = server.store.FinishedBuilds() require.Equal(t, 1, len(builds)) require.Equal(t, 1234, *builds[0].Number) require.Equal(t, "passed", *builds[0].State) @@ -346,7 +341,7 @@ func TestProcessEvent(t *testing.T) { server := NewServer(":8080", logger, config.Config{ BuildkiteWebhookToken: "asdf", - }, mockBq, nil, nil) + }, mockBq) rw := httptest.NewRecorder() body := bytes.NewBufferString(`{ diff --git a/dev/build-tracker/util_test.go b/dev/build-tracker/util_test.go deleted file mode 100644 index a569b500f42..00000000000 --- a/dev/build-tracker/util_test.go +++ /dev/null @@ -1,53 +0,0 @@ -package main - -import ( - "context" - "strings" - "time" - - "github.com/redis/go-redis/v9" - "golang.org/x/exp/maps" - - "github.com/sourcegraph/sourcegraph/dev/build-tracker/build" -) - -func mockRedisClient() *build.MockRedisClient { - bjsons := make(map[string][]byte) - failureCount := 0 - rclient := build.NewMockRedisClient() - rclient.SetFunc.SetDefaultHook(func(ctx context.Context, s string, i interface{}, d time.Duration) *redis.StatusCmd { - if strings.HasPrefix(s, "build/") { - bjsons[s] = i.([]byte) - } else { - failureCount = 0 - } - return redis.NewStatusCmd(context.Background()) - }) - rclient.KeysFunc.SetDefaultHook(func(ctx context.Context, s string) *redis.StringSliceCmd { - return redis.NewStringSliceResult(maps.Keys(bjsons), nil) - }) - rclient.MGetFunc.SetDefaultHook(func(ctx context.Context, s ...string) *redis.SliceCmd { - var result []interface{} - for _, key := range s { - result = append(result, string(bjsons[key])) - } - return redis.NewSliceResult(result, nil) - }) - rclient.DelFunc.PushHook(func(ctx context.Context, s ...string) *redis.IntCmd { - for _, key := range s { - delete(bjsons, key) - } - return redis.NewIntCmd(ctx) - }) - rclient.GetFunc.SetDefaultHook(func(ctx context.Context, s string) *redis.StringCmd { - if b, ok := bjsons[s]; strings.HasPrefix(s, "build/") && ok { - return redis.NewStringResult(string(b), nil) - } - return redis.NewStringResult("", redis.Nil) - }) - rclient.IncrFunc.PushHook(func(ctx context.Context, s string) *redis.IntCmd { - failureCount++ - return redis.NewIntResult(int64(failureCount), nil) - }) - return rclient -} diff --git a/mockgen.test.yaml b/mockgen.test.yaml index 64f9a57b731..b0c1979217c 100644 --- a/mockgen.test.yaml +++ b/mockgen.test.yaml @@ -380,12 +380,6 @@ package: main interfaces: - BigQueryWriter -- filename: dev/build-tracker/build/mocks.go - path: github.com/sourcegraph/sourcegraph/dev/build-tracker/build - package: build - interfaces: - - Locker - - RedisClient - filename: cmd/cody-gateway/internal/actor/productsubscription/productsubscriptiontest/mocks.go package: productsubscriptiontest sources: