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

Function TestSrem

IceFireDB-PubSub/test/cmd_set_test.go:169–225  ·  view source on GitHub ↗

Test SREM

(t *testing.T)

Source from the content-addressed store, hash-verified

167
168// Test SREM
169func TestSrem(t *testing.T) {
170 server.Clear()
171 c, err := proto.Dial(server.Addr())
172 ok(t, err)
173 defer c.Close()
174 s := server.Direct()
175
176 s.SetAdd("s", "aap", "noot", "mies", "vuur")
177
178 {
179 mustDo(t, c,
180 "SREM", "s", "aap", "noot",
181 proto.Int(2),
182 )
183
184 members, err := s.Members("s")
185 ok(t, err)
186 equals(t, []string{"mies", "vuur"}, members)
187 }
188
189 // a nonexisting key
190 must0(t, c,
191 "SREM", "s", "nosuch",
192 proto.Int(9),
193 )
194
195 // a nonexisting key
196 must0(t, c,
197 "SREM", "nosuch", "nosuch",
198 )
199
200 t.Run("direct usage", func(t *testing.T) {
201 b, err := s.SRem("s", "mies")
202 ok(t, err)
203 equals(t, 1, b)
204
205 members, err := s.Members("s")
206 ok(t, err)
207 equals(t, []string{"vuur"}, members)
208 })
209
210 t.Run("errors", func(t *testing.T) {
211 mustOK(t, c, "SET", "str", "value")
212 mustDo(t, c,
213 "SREM", "str", "value",
214 proto.Error(msgWrongType),
215 )
216 mustDo(t, c,
217 "SREM",
218 proto.Error(errWrongNumber("srem")),
219 )
220 mustDo(t, c,
221 "SREM", "set",
222 proto.Error(errWrongNumber("srem")),
223 )
224 })
225}
226

Callers

nothing calls this directly

Calls 14

ClearFunction · 0.92
DialFunction · 0.92
AddrFunction · 0.92
DirectFunction · 0.92
IntFunction · 0.92
ErrorFunction · 0.92
okFunction · 0.70
mustDoFunction · 0.70
equalsFunction · 0.70
must0Function · 0.70
mustOKFunction · 0.70
errWrongNumberFunction · 0.70

Tested by

no test coverage detected