MCPcopy
hub / github.com/redis/go-redis / TestXAdd_TrimLimitArgs

Function TestXAdd_TrimLimitArgs

stream_commands_unit_test.go:116–196  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

114}
115
116func TestXAdd_TrimLimitArgs(t *testing.T) {
117 ctx := context.Background()
118
119 tests := []struct {
120 name string
121 args *XAddArgs
122 want []interface{}
123 }{
124 {
125 name: "approx_limit_omitted",
126 args: &XAddArgs{
127 Stream: "stream",
128 MaxLen: 100,
129 Approx: true,
130 ID: "1-0",
131 Values: []string{"k", "v"},
132 },
133 want: []interface{}{"xadd", "stream", "maxlen", "~", int64(100), "1-0", "k", "v"},
134 },
135 {
136 name: "approx_positive_limit",
137 args: &XAddArgs{
138 Stream: "stream",
139 MaxLen: 100,
140 Approx: true,
141 Limit: 1000,
142 ID: "1-0",
143 Values: []string{"k", "v"},
144 },
145 want: []interface{}{"xadd", "stream", "maxlen", "~", int64(100), "limit", int64(1000), "1-0", "k", "v"},
146 },
147 {
148 name: "approx_limit_disabled",
149 args: &XAddArgs{
150 Stream: "stream",
151 MaxLen: 100,
152 Approx: true,
153 Limit: XTrimLimitDisabled,
154 ID: "1-0",
155 Values: []string{"k", "v"},
156 },
157 want: []interface{}{"xadd", "stream", "maxlen", "~", int64(100), "limit", int64(0), "1-0", "k", "v"},
158 },
159 {
160 name: "minid_approx_limit_disabled",
161 args: &XAddArgs{
162 Stream: "stream",
163 MinID: "4-0",
164 Approx: true,
165 Limit: XTrimLimitDisabled,
166 ID: "5-0",
167 Values: []string{"k", "v"},
168 },
169 want: []interface{}{"xadd", "stream", "minid", "~", "4-0", "limit", int64(0), "5-0", "k", "v"},
170 },
171 {
172 name: "exact_zero_limit_omitted",
173 args: &XAddArgs{

Callers

nothing calls this directly

Calls 4

captureCmdableFunction · 0.85
XAddMethod · 0.65
ArgsMethod · 0.65
RunMethod · 0.45

Tested by

no test coverage detected