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

Function TestIncrBy

IceFireDB-PubSub/test/cmd_string_test.go:507–568  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

505}
506
507func TestIncrBy(t *testing.T) {
508 server.Clear()
509 c, err := proto.Dial(server.Addr())
510 ok(t, err)
511 defer c.Close()
512 s := server.Direct()
513
514 // Existing key
515 {
516 s.Set("foo", "12")
517 mustDo(t, c,
518 "INCRBY", "foo", "400",
519 proto.Int(412),
520 )
521 s.CheckGet(t, "foo", "412")
522 }
523
524 // Existing key, not an integer
525 {
526 s.Set("foo", "noint")
527 mustDo(t, c,
528 "INCRBY", "foo", "400",
529 proto.Error(msgInvalidInt),
530 )
531 }
532
533 // New key
534 {
535 mustDo(t, c,
536 "INCRBY", "bar", "4000",
537 proto.Int(4000),
538 )
539 s.CheckGet(t, "bar", "4000")
540 }
541
542 // Wrong type of existing key
543 {
544 s.HSet("wrong", "aap", "noot")
545 mustDo(t, c,
546 "INCRBY", "wrong", "400",
547 proto.Error(msgWrongType),
548 )
549 }
550
551 // Amount not an integer
552 mustDo(t, c,
553 "INCRBY", "key", "noint",
554 proto.Error(msgInvalidInt),
555 )
556
557 // Wrong usage
558 {
559 mustDo(t, c,
560 "INCRBY",
561 proto.Error(errWrongNumber("incrby")),
562 )
563 mustDo(t, c,
564 "INCRBY", "another", "new", "key",

Callers

nothing calls this directly

Calls 11

ClearFunction · 0.92
DialFunction · 0.92
AddrFunction · 0.92
DirectFunction · 0.92
IntFunction · 0.92
ErrorFunction · 0.92
SetMethod · 0.80
okFunction · 0.70
mustDoFunction · 0.70
errWrongNumberFunction · 0.70
CloseMethod · 0.65

Tested by

no test coverage detected