(t *testing.T)
| 372 | } |
| 373 | |
| 374 | func TestHashIncrby(t *testing.T) { |
| 375 | server.Clear() |
| 376 | |
| 377 | c, err := proto.Dial(server.Addr()) |
| 378 | ok(t, err) |
| 379 | defer c.Close() |
| 380 | |
| 381 | // New key |
| 382 | must1(t, c, "HINCRBY", "hash", "field", "1") |
| 383 | |
| 384 | // Existing key |
| 385 | mustDo(t, c, |
| 386 | "HINCRBY", "hash", "field", "100", |
| 387 | proto.Int(101), |
| 388 | ) |
| 389 | |
| 390 | // Minus works. |
| 391 | mustDo(t, c, |
| 392 | "HINCRBY", "hash", "field", "-12", |
| 393 | proto.Int(101-12), |
| 394 | ) |
| 395 | |
| 396 | t.Run("direct", func(t *testing.T) { |
| 397 | directDo(t, c, "HINCRBY", "hash", "field", -3) |
| 398 | |
| 399 | equals(t, "86", directDoString(t, c, "HGET", "hash", "field")) |
| 400 | }) |
| 401 | |
| 402 | t.Run("errors", func(t *testing.T) { |
| 403 | // Wrong key type |
| 404 | directDoString(t, c, "SET", "str", "cake") |
| 405 | mustDo(t, c, |
| 406 | "HINCRBY", "str", "case", "4", |
| 407 | proto.Error(msgWrongType), |
| 408 | ) |
| 409 | |
| 410 | mustDo(t, c, |
| 411 | "HINCRBY", "str", "case", "foo", |
| 412 | proto.Error("ERR value is not an integer or out of range"), |
| 413 | ) |
| 414 | |
| 415 | mustDo(t, c, |
| 416 | "HINCRBY", "str", |
| 417 | proto.Error(errWrongNumber("HINCRBY")), |
| 418 | ) |
| 419 | }) |
| 420 | } |
| 421 | |
| 422 | func TestHashIncrbyfloat(t *testing.T) { |
| 423 | server.Clear() |
nothing calls this directly
no test coverage detected