Skip to content

Commit

Permalink
fixup! Add More Unit Tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Mark Liu committed Nov 7, 2016
1 parent 543e366 commit e3cb725
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ public class FileChecksumMatcher extends TypeSafeMatcher<PipelineResult>
private String actualChecksum;

public FileChecksumMatcher(String checksum, String filePath) {
this(checksum, filePath, null);
this(checksum, filePath, DEFAULT_SHARD_TEMPLATE);
}

public FileChecksumMatcher(String checksum, String filePath, String shardTemplate) {
Expand Down Expand Up @@ -169,7 +169,7 @@ List<String> readLines(Collection<String> files, IOChannelFactory factory) throw

/**
* Check if total number of files is correct by comparing with the number that
* is parsed from shard name using a name template. If no template are specified,
* is parsed from shard name using a name template. If no template is specified,
* "SSSS-of-NNNN" will be used as default, and "NNNN" will be the expected total
* number of files.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,8 +128,24 @@ public void testMatcherThatVerifiesFileWithEmptyContent() throws IOException {
}

@Test
public void testReadWithRetriesFailsWhenTemplateIncorrect()
throws IOException, InterruptedException {
public void testMatcherThatUsesCustomizedTemplate() throws Exception {
// Customized template: resultSSS-totalNNN
File tmpFile1 = tmpFolder.newFile("result0-total2");
File tmpFile2 = tmpFolder.newFile("result1-total2");
Files.write("To be or not to be, ", tmpFile1, StandardCharsets.UTF_8);
Files.write("it is not a question.", tmpFile2, StandardCharsets.UTF_8);

String customizedTemplate = "result\\d+-total(\\d+)$";
FileChecksumMatcher matcher = new FileChecksumMatcher(
"90552392c28396935fe4f123bd0b5c2d0f6260c8",
IOChannelUtils.resolve(tmpFolder.getRoot().getPath(), "*"),
customizedTemplate);

assertThat(pResult, matcher);
}

@Test
public void testReadWithRetriesFailsWhenTemplateIncorrect() throws Exception {
File tmpFile = tmpFolder.newFile();
Files.write("Test for file checksum verifier.", tmpFile, StandardCharsets.UTF_8);

Expand Down

0 comments on commit e3cb725

Please sign in to comment.