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

Function TestIncrEXFloat_Args

string_commands_unit_test.go:120–178  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

118}
119
120func TestIncrEXFloat_Args(t *testing.T) {
121 tests := []struct {
122 name string
123 args IncrEXFloatArgs
124 want []interface{}
125 }{
126 {
127 name: "default_zero_by",
128 args: IncrEXFloatArgs{},
129 want: []interface{}{"increx", "key", "byfloat", float64(0)},
130 },
131 {
132 name: "byfloat",
133 args: IncrEXFloatArgs{By: 0.25},
134 want: []interface{}{"increx", "key", "byfloat", 0.25},
135 },
136 {
137 name: "bounds_and_saturate",
138 args: IncrEXFloatArgs{
139 By: 0.7,
140 UBound: 2, HasUBound: true,
141 Saturate: true,
142 },
143 want: []interface{}{"increx", "key", "byfloat", 0.7, "ubound", float64(2), "saturate"},
144 },
145 {
146 name: "lbound_ubound",
147 args: IncrEXFloatArgs{
148 By: 0.5,
149 LBound: -1.5, HasLBound: true,
150 UBound: 1.5, HasUBound: true,
151 },
152 want: []interface{}{"increx", "key", "byfloat", 0.5, "lbound", -1.5, "ubound", 1.5},
153 },
154 {
155 name: "ex_and_enx",
156 args: IncrEXFloatArgs{
157 By: 1.5,
158 Expiration: &ExpirationOption{Mode: EX, Value: 30},
159 ENX: true,
160 },
161 want: []interface{}{"increx", "key", "byfloat", 1.5, "ex", int64(30), "enx"},
162 },
163 }
164
165 for _, tt := range tests {
166 t.Run(tt.name, func(t *testing.T) {
167 var captured Cmder
168 c := captureCmdable(&captured)
169 cmd := c.IncrEXFloat(context.Background(), "key", tt.args)
170 if cmd == nil {
171 t.Fatalf("IncrEXFloat returned nil")
172 }
173 if !reflect.DeepEqual(cmd.Args(), tt.want) {
174 t.Errorf("args mismatch\n got: %#v\nwant: %#v", cmd.Args(), tt.want)
175 }
176 })
177 }

Callers

nothing calls this directly

Calls 4

captureCmdableFunction · 0.85
IncrEXFloatMethod · 0.65
ArgsMethod · 0.65
RunMethod · 0.45

Tested by

no test coverage detected