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

Function TestSRems

structure/set_test.go:222–303  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

220}
221
222func TestSRems(t *testing.T) {
223 // Creating a list of cases for testing.
224 tests := []struct {
225 name string
226 setup func(*SetStructure)
227 key string
228 membersRem []string
229 membersWant []string
230 wantErr error
231 ttl int64
232 }{
233 {
234 name: "test empty key ",
235 setup: func(s *SetStructure) {},
236 key: "",
237 membersRem: []string{"key1", "key2"},
238 membersWant: []string{},
239 wantErr: _const.ErrKeyIsEmpty,
240 ttl: 0,
241 },
242 {
243 name: "test when key not found",
244 setup: func(s *SetStructure) {},
245 key: "destination",
246 membersRem: []string{"key1", "key2"},
247 membersWant: []string{},
248 wantErr: _const.ErrKeyNotFound,
249 ttl: 0,
250 },
251 {
252 name: "test when remove one key",
253 setup: func(s *SetStructure) {
254 _ = s.SAdds("destination", 0, "key1", "key2")
255 },
256 key: "destination",
257 membersRem: []string{"key1"},
258 membersWant: []string{"key2"},
259 wantErr: nil,
260 ttl: 0,
261 },
262 {
263 name: "test remove all keys",
264 setup: func(s *SetStructure) {
265 _ = s.SAdds("destination", 0, "key1", "key2")
266 },
267 key: "destination",
268 membersRem: []string{"key1", "key1"},
269 membersWant: []string{},
270 wantErr: nil,
271 ttl: 0,
272 },
273 {
274 name: "test remove FSets that don't exist",
275 setup: func(s *SetStructure) {
276 _ = s.SAdds("destination", 0, "key1", "key2")
277 },
278 key: "destination",
279 membersRem: []string{"key10", "key11"},

Callers

nothing calls this directly

Calls 4

initTestSetDbFunction · 0.85
SAddsMethod · 0.65
SRemsMethod · 0.65
existsMethod · 0.45

Tested by

no test coverage detected