Skip to content

Commit

Permalink
add tolerance to flaky wall-time-checking unit test
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewazores committed Sep 14, 2023
1 parent 7b400c3 commit 05e1447
Showing 1 changed file with 6 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1165,12 +1165,15 @@ public String answer(InvocationOnMock invocation) throws Throwable {
void shouldGetArchivedTimeFromTimestamp() {
// December 19, 2019 | 8:38:34 PM UTC
String timestamp = "20191219T213834Z";
Long time = recordingArchiveHelper.getArchivedTimeFromTimestamp(timestamp);
long time = recordingArchiveHelper.getArchivedTimeFromTimestamp(timestamp);
long expectedArchivedTime = Instant.parse("2019-12-19T21:38:34.00Z").toEpochMilli();
MatcherAssert.assertThat(time, Matchers.equalTo(expectedArchivedTime));

String invalid = "";
Long invalidTime = recordingArchiveHelper.getArchivedTimeFromTimestamp(invalid);
MatcherAssert.assertThat(invalidTime, Matchers.equalTo(Instant.now().toEpochMilli()));
long invalidTime = recordingArchiveHelper.getArchivedTimeFromTimestamp(invalid);
long tolerance = 10;
long now = Instant.now().toEpochMilli();
MatcherAssert.assertThat(invalidTime, Matchers.lessThanOrEqualTo(now + tolerance));
MatcherAssert.assertThat(invalidTime, Matchers.greaterThanOrEqualTo(now - tolerance));
}
}

0 comments on commit 05e1447

Please sign in to comment.