blob: 24cfd4994026363b2868afa9045f713e55fa60da [file] [log] [blame]
Mahir Gunyel82f98dd2023-07-24 10:29:49 +03001package redis
2
3import "time"
4
5// NewCmdResult returns a Cmd initialised with val and err for testing.
6func NewCmdResult(val interface{}, err error) *Cmd {
7 var cmd Cmd
8 cmd.val = val
9 cmd.SetErr(err)
10 return &cmd
11}
12
13// NewSliceResult returns a SliceCmd initialised with val and err for testing.
14func NewSliceResult(val []interface{}, err error) *SliceCmd {
15 var cmd SliceCmd
16 cmd.val = val
17 cmd.SetErr(err)
18 return &cmd
19}
20
21// NewStatusResult returns a StatusCmd initialised with val and err for testing.
22func NewStatusResult(val string, err error) *StatusCmd {
23 var cmd StatusCmd
24 cmd.val = val
25 cmd.SetErr(err)
26 return &cmd
27}
28
29// NewIntResult returns an IntCmd initialised with val and err for testing.
30func NewIntResult(val int64, err error) *IntCmd {
31 var cmd IntCmd
32 cmd.val = val
33 cmd.SetErr(err)
34 return &cmd
35}
36
37// NewDurationResult returns a DurationCmd initialised with val and err for testing.
38func NewDurationResult(val time.Duration, err error) *DurationCmd {
39 var cmd DurationCmd
40 cmd.val = val
41 cmd.SetErr(err)
42 return &cmd
43}
44
45// NewBoolResult returns a BoolCmd initialised with val and err for testing.
46func NewBoolResult(val bool, err error) *BoolCmd {
47 var cmd BoolCmd
48 cmd.val = val
49 cmd.SetErr(err)
50 return &cmd
51}
52
53// NewStringResult returns a StringCmd initialised with val and err for testing.
54func NewStringResult(val string, err error) *StringCmd {
55 var cmd StringCmd
56 cmd.val = val
57 cmd.SetErr(err)
58 return &cmd
59}
60
61// NewFloatResult returns a FloatCmd initialised with val and err for testing.
62func NewFloatResult(val float64, err error) *FloatCmd {
63 var cmd FloatCmd
64 cmd.val = val
65 cmd.SetErr(err)
66 return &cmd
67}
68
69// NewStringSliceResult returns a StringSliceCmd initialised with val and err for testing.
70func NewStringSliceResult(val []string, err error) *StringSliceCmd {
71 var cmd StringSliceCmd
72 cmd.val = val
73 cmd.SetErr(err)
74 return &cmd
75}
76
77// NewBoolSliceResult returns a BoolSliceCmd initialised with val and err for testing.
78func NewBoolSliceResult(val []bool, err error) *BoolSliceCmd {
79 var cmd BoolSliceCmd
80 cmd.val = val
81 cmd.SetErr(err)
82 return &cmd
83}
84
85// NewStringStringMapResult returns a StringStringMapCmd initialised with val and err for testing.
86func NewStringStringMapResult(val map[string]string, err error) *StringStringMapCmd {
87 var cmd StringStringMapCmd
88 cmd.val = val
89 cmd.SetErr(err)
90 return &cmd
91}
92
93// NewStringIntMapCmdResult returns a StringIntMapCmd initialised with val and err for testing.
94func NewStringIntMapCmdResult(val map[string]int64, err error) *StringIntMapCmd {
95 var cmd StringIntMapCmd
96 cmd.val = val
97 cmd.SetErr(err)
98 return &cmd
99}
100
101// NewTimeCmdResult returns a TimeCmd initialised with val and err for testing.
102func NewTimeCmdResult(val time.Time, err error) *TimeCmd {
103 var cmd TimeCmd
104 cmd.val = val
105 cmd.SetErr(err)
106 return &cmd
107}
108
109// NewZSliceCmdResult returns a ZSliceCmd initialised with val and err for testing.
110func NewZSliceCmdResult(val []Z, err error) *ZSliceCmd {
111 var cmd ZSliceCmd
112 cmd.val = val
113 cmd.SetErr(err)
114 return &cmd
115}
116
117// NewZWithKeyCmdResult returns a NewZWithKeyCmd initialised with val and err for testing.
118func NewZWithKeyCmdResult(val *ZWithKey, err error) *ZWithKeyCmd {
119 var cmd ZWithKeyCmd
120 cmd.val = val
121 cmd.SetErr(err)
122 return &cmd
123}
124
125// NewScanCmdResult returns a ScanCmd initialised with val and err for testing.
126func NewScanCmdResult(keys []string, cursor uint64, err error) *ScanCmd {
127 var cmd ScanCmd
128 cmd.page = keys
129 cmd.cursor = cursor
130 cmd.SetErr(err)
131 return &cmd
132}
133
134// NewClusterSlotsCmdResult returns a ClusterSlotsCmd initialised with val and err for testing.
135func NewClusterSlotsCmdResult(val []ClusterSlot, err error) *ClusterSlotsCmd {
136 var cmd ClusterSlotsCmd
137 cmd.val = val
138 cmd.SetErr(err)
139 return &cmd
140}
141
142// NewGeoLocationCmdResult returns a GeoLocationCmd initialised with val and err for testing.
143func NewGeoLocationCmdResult(val []GeoLocation, err error) *GeoLocationCmd {
144 var cmd GeoLocationCmd
145 cmd.locations = val
146 cmd.SetErr(err)
147 return &cmd
148}
149
150// NewGeoPosCmdResult returns a GeoPosCmd initialised with val and err for testing.
151func NewGeoPosCmdResult(val []*GeoPos, err error) *GeoPosCmd {
152 var cmd GeoPosCmd
153 cmd.val = val
154 cmd.SetErr(err)
155 return &cmd
156}
157
158// NewCommandsInfoCmdResult returns a CommandsInfoCmd initialised with val and err for testing.
159func NewCommandsInfoCmdResult(val map[string]*CommandInfo, err error) *CommandsInfoCmd {
160 var cmd CommandsInfoCmd
161 cmd.val = val
162 cmd.SetErr(err)
163 return &cmd
164}
165
166// NewXMessageSliceCmdResult returns a XMessageSliceCmd initialised with val and err for testing.
167func NewXMessageSliceCmdResult(val []XMessage, err error) *XMessageSliceCmd {
168 var cmd XMessageSliceCmd
169 cmd.val = val
170 cmd.SetErr(err)
171 return &cmd
172}
173
174// NewXStreamSliceCmdResult returns a XStreamSliceCmd initialised with val and err for testing.
175func NewXStreamSliceCmdResult(val []XStream, err error) *XStreamSliceCmd {
176 var cmd XStreamSliceCmd
177 cmd.val = val
178 cmd.SetErr(err)
179 return &cmd
180}