This repository has been archived by the owner on May 15, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 9
/
mock.go
71 lines (60 loc) · 1.58 KB
/
mock.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
//nolint:unused
package cache
import (
"context"
"time"
"github.com/stretchr/testify/mock"
)
type Mock struct {
mock.Mock
}
var _ Client = &Mock{}
func (m *Mock) Get(ctx context.Context, key string, data interface{}) error {
args := m.Called(ctx, key, data)
if args.Error(0) != nil {
return args.Error(0)
}
return args.Error(0)
}
func (m *Mock) Set(ctx context.Context, key string, data interface{}, expiration time.Time) error {
args := m.Called(ctx, key, data, expiration)
if args.Error(0) != nil {
return args.Error(0)
}
return args.Error(0)
}
func (m *Mock) Add(ctx context.Context, key string, data interface{}, expiration time.Time) error {
args := m.Called(ctx, key, data, expiration)
if args.Error(0) != nil {
return args.Error(0)
}
return args.Error(0)
}
func (m *Mock) Delete(ctx context.Context, key string) error {
args := m.Called(ctx, key)
if args.Error(0) != nil {
return args.Error(0)
}
return args.Error(0)
}
func (m *Mock) getInt(key string) (uint64, time.Time, error) {
args := m.Called(key)
if args.Error(2) != nil {
return 0, time.Time{}, args.Error(2)
}
return args.Get(0).(uint64), args.Get(1).(time.Time), nil
}
func (m *Mock) Increment(ctx context.Context, key string, delta uint64) (uint64, error) {
args := m.Called(ctx, key, delta)
if args.Error(1) != nil {
return 0, args.Error(1)
}
return args.Get(0).(uint64), nil
}
func (m *Mock) Decrement(ctx context.Context, key string, delta uint64) (uint64, error) {
args := m.Called(ctx, key, delta)
if args.Error(1) != nil {
return 0, args.Error(1)
}
return args.Get(0).(uint64), nil
}