MCPcopy Create free account
hub / github.com/ByteStorage/FlyDB / TestZIncrBy

Function TestZIncrBy

structure/zset_test.go:335–353  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

333 }
334}
335func TestZIncrBy(t *testing.T) {
336 zs, _ := initZSetDB()
337 err := zs.ZIncrBy("", "non-existingMember", 5)
338 if err == nil {
339 t.Error("Expected error for empty key not returned")
340 }
341
342 err = zs.ZIncrBy("key", "non-existingMember", 5)
343 if !assert.ErrorIs(t, err, _const.ErrKeyNotFound) {
344 t.Error("Expected ErrKeyNotFound for non-existing member not returned")
345 }
346 err = zs.ZAdd("key", 1, "existingMember", "")
347 assert.NoError(t, err)
348 err = zs.ZIncrBy("key", "existingMember", 5)
349 assert.NoError(t, err)
350
351 Zset, err := zs.getZSetFromDB(stringToBytesWithKey("key"))
352 assert.Equal(t, 6, Zset.dict["existingMember"].score)
353}
354func TestZRank(t *testing.T) {
355 zs, _ := initZSetDB()
356

Callers

nothing calls this directly

Calls 5

initZSetDBFunction · 0.85
stringToBytesWithKeyFunction · 0.85
getZSetFromDBMethod · 0.80
ZIncrByMethod · 0.65
ZAddMethod · 0.65

Tested by

no test coverage detected