Skip to content

Commit

Permalink
[BqvAC2FK] Fix failing LoadHtmlTest (#3722)
Browse files Browse the repository at this point in the history
  • Loading branch information
vga91 committed Aug 30, 2023
1 parent f0a3a1a commit fd14c01
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions full/src/test/java/apoc/load/LoadHtmlTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
import java.util.Map;
import java.util.Set;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.stream.Stream;

import static apoc.load.LoadHtml.KEY_ERROR;
import static apoc.util.MapUtil.map;
Expand Down Expand Up @@ -96,7 +97,7 @@ public void teardown() {

@Test
public void testParseGeneratedJs() {
testCallGeneratedJsWithBrowser("CHROME");
testCallGeneratedJsWithBrowser(CHROME);
}

@Test
Expand All @@ -108,7 +109,7 @@ public void testParseGeneratedJsWrongConfigs() {
assertWrongConfig(errorInvalidConfig,
map("browser", FIREFOX, "architecture", "dunno"));

assertWrongConfig("Error HTTP 401 executing",
assertWrongConfig("Error HTTP",
map("browser", FIREFOX,
"gitHubToken", "12345",
"forceDownload", true));
Expand All @@ -120,7 +121,8 @@ private void assertWrongConfig(String msgError, Map<String, Object> config) {
map("url", URL_HTML_JS, "query", map("a", "a"), "config", config),
r -> fail("Should fails due to wrong configuration"));
} catch (RuntimeException e) {
assertTrue(e.getMessage().contains(msgError));
String message = e.getMessage();
assertTrue("Current message is: " + message, message.contains(msgError));
}
}

Expand Down Expand Up @@ -517,7 +519,7 @@ private void testCallGeneratedJsWithBrowser(String browser) {
testCall(db, "CALL apoc.load.html($url,$query,$config)",
map("url", URL_HTML_JS,
"query", map("td", "td", "strong", "strong"),
"config", map("browser", browser, "driverVersion", "0.30.0")),
"config", map("browser", browser)),
result -> {
Map<String, Object> value = (Map<String, Object>) result.get("value");
List<Map<String, Object>> tdList = (List<Map<String, Object>>) value.get("td");
Expand All @@ -542,8 +544,11 @@ public static void skipIfBrowserNotPresentOrCompatible(Runnable runnable) {
runnable.run();
} catch (RuntimeException e) {
// The test don't fail if the current chrome/firefox version is incompatible or if the browser is not installed
Stream<String> notPresentOrIncompatible = Stream.of("cannot find Chrome binary", "Cannot find firefox binary",
"browser start-up failure",
"This version of ChromeDriver only supports Chrome version");
final String msg = e.getMessage();
if (!msg.contains("cannot find Chrome binary") && !msg.contains("Cannot find firefox binary")) {
if (notPresentOrIncompatible.noneMatch(msg::contains)) {
throw e;
}
}
Expand Down

0 comments on commit fd14c01

Please sign in to comment.