Fix the output slightly when running nomulus update_premium_list (#2065)

It was previously calling toString() on an Optional<PremiumList> which was
unnecessarily verbose. The existing premium list is required to be present
anyway.
This commit is contained in:
Ben McIlwain
2023-07-06 13:46:28 -04:00
committed by GitHub
parent 845f792044
commit 599a55d5b1
2 changed files with 16 additions and 21 deletions
@@ -134,15 +134,13 @@ class UpdatePremiumListCommandTest<C extends UpdatePremiumListCommand>
@Test
void commandPrompt_failureNoPreviousVersion() {
String fileName = "random";
registry = createTld(fileName, null, null);
registry = createTld("random", null, null);
UpdatePremiumListCommand command = new UpdatePremiumListCommand();
command.name = fileName;
command.name = "random";
IllegalArgumentException thrown = assertThrows(IllegalArgumentException.class, command::prompt);
assertThat(thrown)
.hasMessageThat()
.isEqualTo(
String.format("Could not update premium list %s because it doesn't exist.", fileName));
.isEqualTo("Could not update premium list random because it doesn't exist");
}
@Test
@@ -153,27 +151,22 @@ class UpdatePremiumListCommandTest<C extends UpdatePremiumListCommand>
@Test
void commandPrompt_failureTldFromNameDoesNotExist() {
String fileName = "random";
UpdatePremiumListCommand command = new UpdatePremiumListCommand();
command.name = fileName;
command.name = "random2";
IllegalArgumentException thrown = assertThrows(IllegalArgumentException.class, command::prompt);
assertThat(thrown)
.hasMessageThat()
.isEqualTo(
String.format("Could not update premium list %s because it doesn't exist.", fileName));
.isEqualTo("Could not update premium list random2 because it doesn't exist");
}
@Test
void commandPrompt_failureTldFromInputFileDoesNotExist() {
String fileName = "random";
UpdatePremiumListCommand command = new UpdatePremiumListCommand();
// using tld extracted from file name but this tld is not part of the registry
command.inputFile =
Paths.get(tmpDir.resolve(String.format("%s.txt", fileName)).toFile().getPath());
command.inputFile = Paths.get(tmpDir.resolve("random3.txt").toFile().getPath());
IllegalArgumentException thrown = assertThrows(IllegalArgumentException.class, command::prompt);
assertThat(thrown)
.hasMessageThat()
.isEqualTo(
String.format("Could not update premium list %s because it doesn't exist.", fileName));
.isEqualTo("Could not update premium list random3 because it doesn't exist");
}
}