(t *testing.T)
| 584 | } |
| 585 | |
| 586 | func TestHstrlen(t *testing.T) { |
| 587 | server.Clear() |
| 588 | |
| 589 | c, err := proto.Dial(server.Addr()) |
| 590 | ok(t, err) |
| 591 | defer c.Close() |
| 592 | |
| 593 | t.Run("basic", func(t *testing.T) { |
| 594 | directDo(t, c, "HSET", "myhash", "foo", "bar") |
| 595 | mustDo(t, c, |
| 596 | "HSTRLEN", "myhash", "foo", |
| 597 | proto.Int(3), |
| 598 | ) |
| 599 | }) |
| 600 | |
| 601 | t.Run("no such key", func(t *testing.T) { |
| 602 | directDo(t, c, "HSET", "myhash", "foo", "bar") |
| 603 | must0(t, c, |
| 604 | "HSTRLEN", "myhash", "nosuch", |
| 605 | ) |
| 606 | }) |
| 607 | |
| 608 | t.Run("no such hash", func(t *testing.T) { |
| 609 | directDo(t, c, "HSET", "myhash", "foo", "bar") |
| 610 | must0(t, c, |
| 611 | "HSTRLEN", "yourhash", "foo", |
| 612 | ) |
| 613 | }) |
| 614 | |
| 615 | t.Run("utf8", func(t *testing.T) { |
| 616 | directDo(t, c, "HSET", "myhash", "snow", "☃☃☃") |
| 617 | mustDo(t, c, |
| 618 | "HSTRLEN", "myhash", "snow", |
| 619 | proto.Int(9), |
| 620 | ) |
| 621 | }) |
| 622 | |
| 623 | t.Run("errors", func(t *testing.T) { |
| 624 | mustDo(t, c, |
| 625 | "HSTRLEN", |
| 626 | proto.Error("ERR wrong number of arguments for 'HSTRLEN' command"), |
| 627 | ) |
| 628 | |
| 629 | mustDo(t, c, |
| 630 | "HSTRLEN", "bar", |
| 631 | proto.Error("ERR wrong number of arguments for 'HSTRLEN' command"), |
| 632 | ) |
| 633 | |
| 634 | mustDo(t, c, |
| 635 | "HSTRLEN", "bar", "baz", "bak", |
| 636 | proto.Error("ERR wrong number of arguments for 'HSTRLEN' command"), |
| 637 | ) |
| 638 | |
| 639 | directDoString(t, c, "SET", "notahash", "bar") |
| 640 | mustDo(t, c, |
| 641 | "HSTRLEN", "notahash", "bar", |
| 642 | proto.Error("WRONGTYPE Operation against a key holding the wrong kind of value"), |
| 643 | ) |
nothing calls this directly
no test coverage detected