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.

(cherry picked from commit fa38177)
  • Loading branch information
gsmet committed Nov 15, 2023
1 parent 4e383da commit d6e7fcd
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 d6e7fcd

Please sign in to comment.