Review: not sure if this test is necessary/useful implementation is straightforward where sources are stored in maps and filtered based on options the test is just checking if the filtering works as expected using count of sources
(t *testing.T)
| 150 | // implementation is straightforward where sources are stored in maps and filtered based on options |
| 151 | // the test is just checking if the filtering works as expected using count of sources |
| 152 | func TestSourceFiltering(t *testing.T) { |
| 153 | someSources := []string{ |
| 154 | "alienvault", |
| 155 | "chaos", |
| 156 | "crtsh", |
| 157 | "virustotal", |
| 158 | } |
| 159 | |
| 160 | someExclusions := []string{ |
| 161 | "alienvault", |
| 162 | "virustotal", |
| 163 | } |
| 164 | |
| 165 | tests := []struct { |
| 166 | sources []string |
| 167 | exclusions []string |
| 168 | withAllSources bool |
| 169 | withRecursion bool |
| 170 | expectedLength int |
| 171 | }{ |
| 172 | {someSources, someExclusions, false, false, len(someSources) - len(someExclusions)}, |
| 173 | {someSources, someExclusions, false, true, 1}, |
| 174 | {someSources, someExclusions, true, false, len(AllSources) - len(someExclusions)}, |
| 175 | |
| 176 | {someSources, []string{}, false, false, len(someSources)}, |
| 177 | {someSources, []string{}, true, false, len(AllSources)}, |
| 178 | |
| 179 | {[]string{}, []string{}, false, false, len(expectedDefaultSources)}, |
| 180 | {[]string{}, []string{}, true, false, len(AllSources)}, |
| 181 | {[]string{}, []string{}, true, true, len(expectedDefaultRecursiveSources)}, |
| 182 | } |
| 183 | for index, test := range tests { |
| 184 | t.Run(strconv.Itoa(index+1), func(t *testing.T) { |
| 185 | agent := New(test.sources, test.exclusions, test.withAllSources, test.withRecursion) |
| 186 | |
| 187 | for _, v := range agent.sources { |
| 188 | fmt.Println(v.Name()) |
| 189 | } |
| 190 | |
| 191 | assert.Equal(t, test.expectedLength, len(agent.sources)) |
| 192 | agent = nil |
| 193 | }) |
| 194 | } |
| 195 | } |