(t *testing.T)
| 420 | } |
| 421 | |
| 422 | func TestHashIncrbyfloat(t *testing.T) { |
| 423 | server.Clear() |
| 424 | |
| 425 | c, err := proto.Dial(server.Addr()) |
| 426 | ok(t, err) |
| 427 | defer c.Close() |
| 428 | |
| 429 | // Existing key |
| 430 | { |
| 431 | directDo(t, c, "HSET", "hash", "field", "12") |
| 432 | mustDo(t, c, |
| 433 | "HINCRBYFLOAT", "hash", "field", "400.12", |
| 434 | proto.String("412.12"), |
| 435 | ) |
| 436 | equals(t, "412.12", directDoString(t, c, "HGET", "hash", "field")) |
| 437 | } |
| 438 | |
| 439 | // Existing key, not a number |
| 440 | { |
| 441 | directDo(t, c, "HSET", "hash", "field", "noint") |
| 442 | mustDo(t, c, |
| 443 | "HINCRBYFLOAT", "hash", "field", "400", |
| 444 | proto.Error("ERR value is not a valid float"), |
| 445 | ) |
| 446 | } |
| 447 | |
| 448 | // New key |
| 449 | { |
| 450 | mustDo(t, c, |
| 451 | "HINCRBYFLOAT", "hash", "newfield", "40.33", |
| 452 | proto.String("40.33"), |
| 453 | ) |
| 454 | equals(t, "40.33", directDoString(t, c, "HGET", "hash", "newfield")) |
| 455 | } |
| 456 | |
| 457 | t.Run("direct", func(t *testing.T) { |
| 458 | directDo(t, c, "HSET", "hash", "field", "500.1") |
| 459 | equals(t, "500.1", directDoString(t, c, "HGET", "hash", "field")) |
| 460 | // f, err := s.HIncrfloat("hash", "field", 12) |
| 461 | f, err := directDoFloatErr(t, c, "HINCRBYFLOAT", "hash", "field", "12") |
| 462 | ok(t, err) |
| 463 | equalFloat(t, 512.1, f) |
| 464 | }) |
| 465 | |
| 466 | t.Run("errors", func(t *testing.T) { |
| 467 | directDoString(t, c, "SET", "wrong", "type") |
| 468 | mustDo(t, c, |
| 469 | "HINCRBYFLOAT", "wrong", "type", "400", |
| 470 | proto.Error(msgWrongType), |
| 471 | ) |
| 472 | mustDo(t, c, |
| 473 | "HINCRBYFLOAT", |
| 474 | proto.Error(errWrongNumber("HINCRBYFLOAT")), |
| 475 | ) |
| 476 | mustDo(t, c, |
| 477 | "HINCRBYFLOAT", "wrong", |
| 478 | proto.Error(errWrongNumber("HINCRBYFLOAT")), |
| 479 | ) |
nothing calls this directly
no test coverage detected