Skip to content

Commit

Permalink
all but bad test
Browse files Browse the repository at this point in the history
  • Loading branch information
aarsilv committed Apr 5, 2024
1 parent 9d3a4d8 commit f547643
Showing 1 changed file with 14 additions and 27 deletions.
41 changes: 14 additions & 27 deletions eppo/src/androidTest/java/cloud/eppo/android/EppoClientTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -131,8 +131,7 @@ private void deleteCacheFiles() {
deleteFileIfExists(CACHE_FILE_NAME);
}

private void initClient(String host, boolean throwOnCallackError, boolean shouldDeleteCacheFiles, boolean isGracefulMode)
throws InterruptedException {
private void initClient(String host, boolean throwOnCallackError, boolean shouldDeleteCacheFiles, boolean isGracefulMode) {
if (shouldDeleteCacheFiles) {
deleteCacheFiles();
}
Expand All @@ -158,8 +157,12 @@ public void onError(String errorMessage) {
})
.buildAndInit();

if(!lock.await(10000, TimeUnit.MILLISECONDS)) {
throw new RuntimeException("Request for RAC did not complete within timeout");
try {
if (!lock.await(10000, TimeUnit.MILLISECONDS)) {
throw new RuntimeException("Request for RAC did not complete within timeout");
}
} catch (InterruptedException e) {
throw new RuntimeException(e);
}
}

Expand All @@ -170,21 +173,13 @@ public void teardown() {

@Test
public void testAssignments() {
try {
initClient(TEST_HOST, true, true, false);
} catch (InterruptedException e) {
throw new RuntimeException(e);
}
initClient(TEST_HOST, true, true, false);
runTestCases();
}

@Test
public void testErrorGracefulModeOn() {
try {
initClient(TEST_HOST, false, true, true);
} catch (InterruptedException e) {
throw new RuntimeException(e);
}
initClient(TEST_HOST, false, true, true);

EppoClient realClient = EppoClient.getInstance();
EppoClient spyClient = spy(realClient);
Expand Down Expand Up @@ -213,11 +208,7 @@ public void testErrorGracefulModeOn() {

@Test
public void testErrorGracefulModeOff() {
try {
initClient(TEST_HOST, false, true, false);
} catch (InterruptedException e) {
throw new RuntimeException(e);
}
initClient(TEST_HOST, false, true, false);

EppoClient realClient = EppoClient.getInstance();
EppoClient spyClient = spy(realClient);
Expand Down Expand Up @@ -253,7 +244,7 @@ private void runTestCases() {
}
System.out.println("We ran this many tests: " + testsRan);
assertTrue("Did not run any test cases", testsRan > 0);
} catch (Exception e) {
} catch (IOException e) {
throw new RuntimeException(e);
}
}
Expand Down Expand Up @@ -385,7 +376,7 @@ public void testInvalidConfigJSON() {


initClient(TEST_HOST, true, true, false);
} catch (InterruptedException | NoSuchFieldException | IllegalAccessException e) {
} catch (NoSuchFieldException | IllegalAccessException e) {
throw new RuntimeException(e);
} finally {
if (httpClientOverrideField != null) {
Expand Down Expand Up @@ -413,12 +404,8 @@ public void testCachedBadResponseAllowsLaterFetching() {
} catch (IOException e) {
throw new RuntimeException(e);
}
try {
initClient(TEST_HOST, false, false, false);
} catch (InterruptedException e) {
throw new RuntimeException(e);
};

initClient(TEST_HOST, false, false, false);
;
String result = EppoClient.getInstance().getStringAssignment("dummy subject", "dummy flag");
assertNull(result);
// Failure callback will have fired from cache read error, but configuration request will still be fired off on init
Expand Down

0 comments on commit f547643

Please sign in to comment.