Skip to content

Commit

Permalink
Merge pull request #74 from Tinder/add_test_coverage_stack_overflow
Browse files Browse the repository at this point in the history
Add test for stack overflow situation
  • Loading branch information
tinder-maxwellelliott authored Jul 6, 2021
2 parents 4310ea8 + dded975 commit d642f32
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions test/java/com/bazel_diff/TargetHashingClientImplTests.java
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,26 @@ public void hashAllBazelTargets_ruleTargets_ruleInputs() throws IOException, NoS
}
}

@Test
public void hashAllBazelTargets_ruleTargets_ruleInputsWithSelfInput() throws IOException, NoSuchAlgorithmException {
List<String> ruleInputs = new ArrayList<>();
ruleInputs.add("rule1");
ruleInputs.add("rule4");
BazelTarget rule3 = createRuleTarget("rule3", ruleInputs, "digest");
defaultTargets.add(rule3);
BazelTarget rule4 = createRuleTarget("rule4", ruleInputs, "digest2");
defaultTargets.add(rule4);
when(bazelClientMock.queryAllTargets()).thenReturn(defaultTargets);
TargetHashingClientImpl client = new TargetHashingClientImpl(bazelClientMock, filesClientMock);
try {
Map<String, String> hash = client.hashAllBazelTargetsAndSourcefiles(new HashSet<>());
assertEquals(4, hash.size());
assertEquals("bf15e616e870aaacb02493ea0b8e90c6c750c266fa26375e22b30b78954ee523", hash.get("rule4"));
} catch (IOException | NoSuchAlgorithmException e) {
fail(e.getMessage());
}
}

private BazelTarget createRuleTarget(String ruleName, List<String> ruleInputs, String ruleDigest) throws NoSuchAlgorithmException {
BazelTarget target = mock(BazelTarget.class);
BazelRule rule = mock(BazelRule.class);
Expand Down

0 comments on commit d642f32

Please sign in to comment.