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

Function TestHashIncr

hashes_test.go:146–180  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

144 t.Fatal(n)
145 }
146}
147
148func TestHashIncr(t *testing.T) {
149 c := getTestConn()
150
151 ctx := context.Background()
152 key := []byte("c")
153 if n, err := c.Do(ctx, "hincrby", key, 1, 1).Int64(); err != nil {
154 t.Fatal(err)
155 } else if n != 1 {
156 t.Fatal(err)
157 }
158
159 if n, err := c.Do(ctx, "hlen", key).Int64(); err != nil {
160 t.Fatal(err)
161 } else if n != 1 {
162 t.Fatal(n)
163 }
164
165 if n, err := c.Do(ctx, "hincrby", key, 1, 10).Int64(); err != nil {
166 t.Fatal(err)
167 } else if n != 11 {
168 t.Fatal(err)
169 }
170
171 if n, err := c.Do(ctx, "hlen", key).Int64(); err != nil {
172 t.Fatal(err)
173 } else if n != 1 {
174 t.Fatal(n)
175 }
176
177 if n, err := c.Do(ctx, "hincrby", key, 1, -11).Int64(); err != nil {
178 t.Fatal(err)
179 } else if n != 0 {
180 t.Fatal(err)
181 }
182}
183

Callers

nothing calls this directly

Calls 2

getTestConnFunction · 0.85
DoMethod · 0.45

Tested by

no test coverage detected