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

Function TestKVIncrDecr

strings_test.go:354–387  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

352}
353
354func TestKVIncrDecr(t *testing.T) {
355 c := getTestConn()
356
357 ctx := context.Background()
358 if n, err := c.Incr(ctx, "n").Result(); err != nil {
359 t.Error(err)
360 } else if n != 1 {
361 t.Error(n)
362 }
363
364 if n, err := c.Incr(ctx, "n").Result(); err != nil {
365 t.Error(err)
366 } else if n != 2 {
367 t.Error(n)
368 }
369
370 if n, err := c.Decr(ctx, "n").Result(); err != nil {
371 t.Error(err)
372 } else if n != 1 {
373 t.Error(n)
374 }
375
376 if n, err := c.IncrBy(ctx, "n", 10).Result(); err != nil {
377 t.Error(err)
378 } else if n != 11 {
379 t.Error(n)
380 }
381
382 if n, err := c.DecrBy(ctx, "n", 10).Result(); err != nil {
383 t.Error(err)
384 } else if n != 1 {
385 t.Error(n)
386 }
387}
388
389func TestKVErrorParams(t *testing.T) {
390 c := getTestConn()

Callers

nothing calls this directly

Calls 2

getTestConnFunction · 0.85
ErrorMethod · 0.45

Tested by

no test coverage detected