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

Function TestHashIncrby

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

Source from the content-addressed store, hash-verified

372}
373
374func TestHashIncrby(t *testing.T) {
375 server.Clear()
376
377 c, err := proto.Dial(server.Addr())
378 ok(t, err)
379 defer c.Close()
380
381 // New key
382 must1(t, c, "HINCRBY", "hash", "field", "1")
383
384 // Existing key
385 mustDo(t, c,
386 "HINCRBY", "hash", "field", "100",
387 proto.Int(101),
388 )
389
390 // Minus works.
391 mustDo(t, c,
392 "HINCRBY", "hash", "field", "-12",
393 proto.Int(101-12),
394 )
395
396 t.Run("direct", func(t *testing.T) {
397 directDo(t, c, "HINCRBY", "hash", "field", -3)
398
399 equals(t, "86", directDoString(t, c, "HGET", "hash", "field"))
400 })
401
402 t.Run("errors", func(t *testing.T) {
403 // Wrong key type
404 directDoString(t, c, "SET", "str", "cake")
405 mustDo(t, c,
406 "HINCRBY", "str", "case", "4",
407 proto.Error(msgWrongType),
408 )
409
410 mustDo(t, c,
411 "HINCRBY", "str", "case", "foo",
412 proto.Error("ERR value is not an integer or out of range"),
413 )
414
415 mustDo(t, c,
416 "HINCRBY", "str",
417 proto.Error(errWrongNumber("HINCRBY")),
418 )
419 })
420}
421
422func TestHashIncrbyfloat(t *testing.T) {
423 server.Clear()

Callers

nothing calls this directly

Calls 14

ClearFunction · 0.92
DialFunction · 0.92
AddrFunction · 0.92
IntFunction · 0.92
ErrorFunction · 0.92
okFunction · 0.70
must1Function · 0.70
mustDoFunction · 0.70
directDoFunction · 0.70
equalsFunction · 0.70
directDoStringFunction · 0.70
errWrongNumberFunction · 0.70

Tested by

no test coverage detected