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

Function TestIncrbyfloat

IceFireDB-Redis-Proxy/test/cmd_string_test.go:570–644  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

568}
569
570func TestIncrbyfloat(t *testing.T) {
571 server.Clear()
572 c, err := proto.Dial(server.Addr())
573 ok(t, err)
574 defer c.Close()
575 s := server.Direct()
576
577 // Existing key
578 {
579 s.Set("foo", "12")
580 mustDo(t, c,
581 "INCRBYFLOAT", "foo", "400.12",
582 proto.String("412.12"),
583 )
584 s.CheckGet(t, "foo", "412.12")
585 }
586
587 // Existing key, not a number
588 {
589 s.Set("foo", "noint")
590 mustDo(t, c,
591 "INCRBYFLOAT", "foo", "400",
592 proto.Error(msgInvalidFloat),
593 )
594 }
595
596 // New key
597 {
598 mustDo(t, c,
599 "INCRBYFLOAT", "bar", "40.33",
600 proto.String("40.33"),
601 )
602 s.CheckGet(t, "bar", "40.33")
603 }
604
605 // Direct usage
606 {
607 s.Set("foo", "500.1")
608 f, err := s.Incrfloat("foo", 12)
609 ok(t, err)
610 equals(t, 512.1, f)
611 s.CheckGet(t, "foo", "512.1")
612
613 s.HSet("wrong", "aap", "noot")
614 _, err = s.Incrfloat("wrong", 12)
615 assert(t, err != nil, "do s.Incrfloat() error")
616 }
617
618 // Wrong type of existing key
619 {
620 s.HSet("wrong", "aap", "noot")
621 mustDo(t, c,
622 "INCRBYFLOAT", "wrong", "400",
623 proto.Error(msgWrongType),
624 )
625 }
626
627 // Amount not a number

Callers

nothing calls this directly

Calls 13

ClearFunction · 0.92
DialFunction · 0.92
AddrFunction · 0.92
DirectFunction · 0.92
StringFunction · 0.92
ErrorFunction · 0.92
SetMethod · 0.80
okFunction · 0.70
mustDoFunction · 0.70
equalsFunction · 0.70
assertFunction · 0.70
errWrongNumberFunction · 0.70

Tested by

no test coverage detected