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

Function TestSIsMember

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

Source from the content-addressed store, hash-verified

462}
463
464func TestSIsMember(t *testing.T) {
465 // Creating a list of cases for testing.
466 tests := []struct {
467 name string
468 setup func(*SetStructure)
469 key string
470 member string
471 want bool
472 wantErr error
473 }{
474 {
475 name: "test when key empty",
476 setup: func(s *SetStructure) {},
477 key: "",
478 want: false,
479 wantErr: _const.ErrKeyIsEmpty,
480 },
481 {
482 name: "test two members, is member",
483 setup: func(s *SetStructure) {
484 _ = s.SAdds("destination", 0, "mem1", "mem2")
485 },
486 key: "destination",
487 member: "mem2",
488 want: true,
489 wantErr: nil,
490 },
491 {
492 name: "test three members, not member",
493 setup: func(s *SetStructure) {
494 _ = s.SAdds("destination", 0, "mem1", "mem2", "mem1")
495 },
496 key: "destination",
497 member: "mem3",
498 want: false,
499 wantErr: nil,
500 },
501 }
502
503 for _, tt := range tests {
504 t.Run(tt.name, func(t *testing.T) {
505 s, _ := initTestSetDb()
506 tt.setup(s)
507 // Call the method with test case parameters.
508 got, err := s.SIsMember(tt.key, tt.member)
509 assert.Equal(t, tt.wantErr, err)
510 assert.Equal(t, tt.want, got)
511 })
512 }
513}
514
515func TestSUnion(t *testing.T) {
516 // Creating a list of cases for testing.

Callers

nothing calls this directly

Calls 3

initTestSetDbFunction · 0.85
SAddsMethod · 0.65
SIsMemberMethod · 0.65

Tested by

no test coverage detected