Skip to content

Commit

Permalink
Fix tests for win
Browse files Browse the repository at this point in the history
  • Loading branch information
jvalkeal committed May 28, 2022
1 parent 2af4e86 commit a673310
Showing 1 changed file with 9 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -121,14 +121,16 @@ public void testCommandHelp() throws Exception {
.and()
.build();
commandCatalog.register(registration);
CharSequence help = this.help.help("first-command").toString();
String help = this.help.help("first-command").toString();
help = removeNewLines(help);
assertThat(help).isEqualTo(sample());
}

@Test
public void testCommandListDefault() throws Exception {
registerCommandListCommands();
String list = this.help.help(null).toString();
list = removeNewLines(list);
assertThat(list).isEqualTo(sample());
}

Expand All @@ -137,6 +139,7 @@ public void testCommandListFlat() throws Exception {
registerCommandListCommands();
this.help.setShowGroups(false);
String list = this.help.help(null).toString();
list = removeNewLines(list);
assertThat(list).isEqualTo(sample());
}

Expand All @@ -147,9 +150,13 @@ public void testUnknownCommand() throws Exception {
}).isInstanceOf(IllegalArgumentException.class);
}

private String removeNewLines(String str) {
return str.replace("\r", "").replace("\n", "");
}

private String sample() throws IOException {
InputStream is = new ClassPathResource(HelpTests.class.getSimpleName() + "-" + testName + ".txt", HelpTests.class).getInputStream();
return FileCopyUtils.copyToString(new InputStreamReader(is, "UTF-8")).replace("&", "");
return removeNewLines(FileCopyUtils.copyToString(new InputStreamReader(is, "UTF-8")));
}

private void registerCommandListCommands() throws Exception {
Expand Down

0 comments on commit a673310

Please sign in to comment.