Test ZINCRBY
(t *testing.T)
| 1257 | |
| 1258 | // Test ZINCRBY |
| 1259 | func TestSortedSetIncrby(t *testing.T) { |
| 1260 | server.Clear() |
| 1261 | c, err := proto.Dial(server.Addr()) |
| 1262 | ok(t, err) |
| 1263 | defer c.Close() |
| 1264 | s := server.Direct() |
| 1265 | |
| 1266 | // Normal cases |
| 1267 | { |
| 1268 | // New key |
| 1269 | mustDo(t, c, |
| 1270 | "ZINCRBY", "z", "1", "member", |
| 1271 | proto.String("1"), |
| 1272 | ) |
| 1273 | |
| 1274 | // Existing key |
| 1275 | mustDo(t, c, |
| 1276 | "ZINCRBY", "z", "2.5", "member", |
| 1277 | proto.String("3.5"), |
| 1278 | ) |
| 1279 | |
| 1280 | // New member |
| 1281 | mustDo(t, c, |
| 1282 | "ZINCRBY", "z", "1", "othermember", |
| 1283 | proto.String("1"), |
| 1284 | ) |
| 1285 | } |
| 1286 | |
| 1287 | t.Run("errors", func(t *testing.T) { |
| 1288 | mustDo(t, c, |
| 1289 | "ZINCRBY", |
| 1290 | proto.Error(errWrongNumber("zincrby")), |
| 1291 | ) |
| 1292 | mustDo(t, c, |
| 1293 | "ZINCRBY", "set", |
| 1294 | proto.Error(errWrongNumber("zincrby")), |
| 1295 | ) |
| 1296 | mustDo(t, c, |
| 1297 | "ZINCRBY", "set", "nofloat", "a", |
| 1298 | proto.Error(msgInvalidFloat), |
| 1299 | ) |
| 1300 | mustDo(t, c, |
| 1301 | "ZINCRBY", "set", "1.0", "too", "many", |
| 1302 | proto.Error(errWrongNumber("zincrby")), |
| 1303 | ) |
| 1304 | |
| 1305 | s.Set("str", "value") |
| 1306 | mustDo(t, c, |
| 1307 | "ZINCRBY", "str", "1.0", "member", |
| 1308 | proto.Error(msgWrongType), |
| 1309 | ) |
| 1310 | }) |
| 1311 | } |
| 1312 | |
| 1313 | func TestZscan(t *testing.T) { |
| 1314 | server.Clear() |
nothing calls this directly
no test coverage detected