Skip to content

Commit

Permalink
Merge pull request #326 from avimanyum/reset_exclude_list
Browse files Browse the repository at this point in the history
Resetting the list of orgs to include or exclude in the search for each image
  • Loading branch information
afalko authored Mar 10, 2022
2 parents 51c97da + 9ea7bc8 commit 859c50c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -177,10 +177,11 @@ protected Optional<List<PagedSearchIterable<GHContent>>> getSearchResultsExcludi
Optional<List<PagedSearchIterable<GHContent>>> contentsForOrgWithMaximumHits;
contentsForOrgWithMaximumHits = findFilesWithImage(image, orgsToInclude, gitApiSearchLimit);

orgsToExclude.put(orgWithMaximumHits, false);
log.info("Running search by excluding the orgs {}.", orgsToExclude.keySet().toString());
final Map<String, Boolean> orgsToExcludeFromSearch = new HashMap<>(orgsToExclude);
orgsToExcludeFromSearch.put(orgWithMaximumHits, false);
log.info("Running search by excluding the orgs {}.", orgsToExcludeFromSearch.keySet());
Optional<List<PagedSearchIterable<GHContent>>> contentsExcludingOrgWithMaximumHits;
contentsExcludingOrgWithMaximumHits = findFilesWithImage(image, orgsToExclude, gitApiSearchLimit);
contentsExcludingOrgWithMaximumHits = findFilesWithImage(image, orgsToExcludeFromSearch, gitApiSearchLimit);
if (contentsForOrgWithMaximumHits.isPresent()) {
allContentsWithImage.addAll(contentsForOrgWithMaximumHits.get());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -330,6 +330,8 @@ public void getSearchResultsExcludingOrgWithMostHits() throws Exception {
Map<String, Boolean> orgsToIncludeOrExclude = new HashMap<>();

assertEquals((dockerfileGitHubUtil.getSearchResultsExcludingOrgWithMostHits("image", contentsWithImage, orgsToIncludeOrExclude, 1000)).get().size(), 2);
//This check ensures that the parameter passed to the method is not modified. Instead, the method creates a local copy of the map and modifies that.
assertEquals(orgsToIncludeOrExclude.size(), 0);
}

@Test
Expand Down

0 comments on commit 859c50c

Please sign in to comment.