| 1032 | } |
| 1033 | |
| 1034 | func TestFSetsExists(t *testing.T) { |
| 1035 | tests := []struct { |
| 1036 | name string |
| 1037 | setup func(sets *FSets) |
| 1038 | key string |
| 1039 | members []string |
| 1040 | found bool |
| 1041 | }{ |
| 1042 | { |
| 1043 | name: "test when empty Set", |
| 1044 | setup: func(s *FSets) {}, |
| 1045 | key: "testKey", |
| 1046 | members: []string{"key1", "key2"}, |
| 1047 | found: false, |
| 1048 | }, |
| 1049 | { |
| 1050 | name: "test Set with no members found", |
| 1051 | setup: func(fs *FSets) { |
| 1052 | fs.add("non1", "non2") |
| 1053 | }, |
| 1054 | key: "testKey", |
| 1055 | members: []string{"key1", "key2"}, |
| 1056 | found: false, |
| 1057 | }, |
| 1058 | { |
| 1059 | name: "test Set with partial members found", |
| 1060 | setup: func(fs *FSets) { |
| 1061 | fs.add("key1", "non2") |
| 1062 | }, |
| 1063 | key: "testKey", |
| 1064 | members: []string{"key1", "key2"}, |
| 1065 | found: false, |
| 1066 | }, |
| 1067 | { |
| 1068 | name: "test Set with all members found", |
| 1069 | setup: func(fs *FSets) { |
| 1070 | fs.add("key1", "non2", "key2") |
| 1071 | }, |
| 1072 | key: "testKey", |
| 1073 | members: []string{"key1", "key2"}, |
| 1074 | found: true, |
| 1075 | }, |
| 1076 | } |
| 1077 | for _, tt := range tests { |
| 1078 | t.Run(tt.name, func(t *testing.T) { |
| 1079 | testFSets := &FSets{} |
| 1080 | tt.setup(testFSets) |
| 1081 | |
| 1082 | if tt.found { |
| 1083 | assert.True(t, testFSets.exists(tt.members...)) |
| 1084 | } else { |
| 1085 | assert.False(t, testFSets.exists(tt.members...)) |
| 1086 | } |
| 1087 | }) |
| 1088 | } |
| 1089 | } |
| 1090 | |
| 1091 | func TestFSets_remove(t *testing.T) { |