forked from elliotchance/redismock
/
h_cmd.go
119 lines (89 loc) Β· 3.23 KB
/
h_cmd.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
package redismock
import (
"context"
"github.com/go-redis/redis/v8"
)
func (m *ClientMock) HDel(ctx context.Context, key string, fields ...string) *redis.IntCmd {
if !m.hasStub("HDel") {
return m.client.HDel(ctx, key, fields...)
}
return m.Called(ctx, key, fields).Get(0).(*redis.IntCmd)
}
func (m *ClientMock) HExists(ctx context.Context, key, field string) *redis.BoolCmd {
if !m.hasStub("HExists") {
return m.client.HExists(ctx, key, field)
}
return m.Called(ctx, key, field).Get(0).(*redis.BoolCmd)
}
func (m *ClientMock) HGet(ctx context.Context, key, field string) *redis.StringCmd {
if !m.hasStub("HGet") {
return m.client.HGet(ctx, key, field)
}
return m.Called(ctx, key, field).Get(0).(*redis.StringCmd)
}
func (m *ClientMock) HGetAll(ctx context.Context, key string) *redis.StringStringMapCmd {
if !m.hasStub("HGetAll") {
return m.client.HGetAll(ctx, key)
}
return m.Called(ctx, key).Get(0).(*redis.StringStringMapCmd)
}
func (m *ClientMock) HIncrBy(ctx context.Context, key, field string, incr int64) *redis.IntCmd {
if !m.hasStub("HIncrBy") {
return m.client.HIncrBy(ctx, key, field, incr)
}
return m.Called(ctx, key, field, incr).Get(0).(*redis.IntCmd)
}
func (m *ClientMock) HIncrByFloat(ctx context.Context, key, field string, incr float64) *redis.FloatCmd {
if !m.hasStub("HIncrByFloat") {
return m.client.HIncrByFloat(ctx, key, field, incr)
}
return m.Called(ctx, key, field, incr).Get(0).(*redis.FloatCmd)
}
func (m *ClientMock) HKeys(ctx context.Context, key string) *redis.StringSliceCmd {
if !m.hasStub("HKeys") {
return m.client.HKeys(ctx, key)
}
return m.Called(ctx, key).Get(0).(*redis.StringSliceCmd)
}
func (m *ClientMock) HLen(ctx context.Context, key string) *redis.IntCmd {
if !m.hasStub("HLen") {
return m.client.HLen(ctx, key)
}
return m.Called(ctx, key).Get(0).(*redis.IntCmd)
}
func (m *ClientMock) HMGet(ctx context.Context, key string, fields ...string) *redis.SliceCmd {
if !m.hasStub("HMGet") {
return m.client.HMGet(ctx, key, fields...)
}
return m.Called(ctx, key, fields).Get(0).(*redis.SliceCmd)
}
func (m *ClientMock) HMSet(ctx context.Context, key string, fields ...interface{}) *redis.BoolCmd {
if !m.hasStub("HMSet") {
return m.client.HMSet(ctx, key, fields)
}
return m.Called(ctx, key, fields).Get(0).(*redis.BoolCmd)
}
func (m *ClientMock) HSet(ctx context.Context, key string, values ...interface{}) *redis.IntCmd {
if !m.hasStub("HSet") {
return m.client.HSet(ctx, key, values)
}
return m.Called(ctx, key, values).Get(0).(*redis.IntCmd)
}
func (m *ClientMock) HSetNX(ctx context.Context, key, field string, value interface{}) *redis.BoolCmd {
if !m.hasStub("HSetNX") {
return m.client.HSetNX(ctx, key, field, value)
}
return m.Called(ctx, key, field, value).Get(0).(*redis.BoolCmd)
}
func (m *ClientMock) HVals(ctx context.Context, key string) *redis.StringSliceCmd {
if !m.hasStub("HVals") {
return m.client.HVals(ctx, key)
}
return m.Called(ctx, key).Get(0).(*redis.StringSliceCmd)
}
func (m *ClientMock) HScan(ctx context.Context, key string, cursor uint64, match string, count int64) *redis.ScanCmd {
if !m.hasStub("HScan") {
return m.client.HScan(ctx, key, cursor, match, count)
}
return m.Called(ctx, key, cursor, match, count).Get(0).(*redis.ScanCmd)
}