Skip to content

Commit

Permalink
Make analytics tests more a bit more resilient
Browse files Browse the repository at this point in the history
We have seen several failures lately, let's hope this fixes it.
  • Loading branch information
gsmet committed Nov 15, 2023
1 parent 8798d17 commit fa38177
Showing 1 changed file with 27 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -66,25 +66,36 @@ void testConsoleQuestion_no() throws IOException {

@Test
void testConsoleQuestion_promptTimeout() throws IOException {
System.setProperty("quarkus.analytics.prompt.timeout", "0");
assertFalse(fileLocations.getLocalConfigFile().toFile().exists());
service.buildAnalyticsUserInput((String prompt) -> {
assertEquals(ACCEPTANCE_PROMPT, prompt);
return "n";
});
assertFalse(fileLocations.getLocalConfigFile().toFile().exists());
System.clearProperty("quarkus.analytics.prompt.timeout");
try {
System.setProperty("quarkus.analytics.prompt.timeout", "0");
assertFalse(fileLocations.getLocalConfigFile().toFile().exists());
service.buildAnalyticsUserInput((String prompt) -> {
assertEquals(ACCEPTANCE_PROMPT, prompt);
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
throw new RuntimeException(e);
}
return "n";
});
assertFalse(fileLocations.getLocalConfigFile().toFile().exists());
} finally {
System.clearProperty("quarkus.analytics.prompt.timeout");
}
}

@Test
void testConsoleQuestion_AnalyticsDisabled() throws IOException {
System.setProperty("quarkus.analytics.disabled", "true");
assertFalse(fileLocations.getLocalConfigFile().toFile().exists());
service.buildAnalyticsUserInput((String prompt) -> {
fail("Prompt should be disabled");
return "n";
});
assertFalse(fileLocations.getLocalConfigFile().toFile().exists());
System.clearProperty("quarkus.analytics.disabled");
try {
System.setProperty("quarkus.analytics.disabled", "true");
assertFalse(fileLocations.getLocalConfigFile().toFile().exists());
service.buildAnalyticsUserInput((String prompt) -> {
fail("Prompt should be disabled");
return "n";
});
assertFalse(fileLocations.getLocalConfigFile().toFile().exists());
} finally {
System.clearProperty("quarkus.analytics.disabled");
}
}
}

0 comments on commit fa38177

Please sign in to comment.