MCPcopy Create free account
hub / github.com/IceFireDB/IceFireDB / TestHstrlen

Function TestHstrlen

IceFireDB-PubSub/test/cmd_hash_test.go:586–645  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

584}
585
586func 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 )

Callers

nothing calls this directly

Calls 12

ClearFunction · 0.92
DialFunction · 0.92
AddrFunction · 0.92
IntFunction · 0.92
ErrorFunction · 0.92
okFunction · 0.70
directDoFunction · 0.70
mustDoFunction · 0.70
must0Function · 0.70
directDoStringFunction · 0.70
CloseMethod · 0.65
RunMethod · 0.45

Tested by

no test coverage detected