Skip to content

Commit

Permalink
fixed unit test for cache size calculation
Browse files Browse the repository at this point in the history
  • Loading branch information
n0y committed Dec 3, 2021
1 parent 2afd6cb commit 6f4f529
Showing 1 changed file with 3 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -197,8 +197,8 @@ class WhenConnectingTests {
class WhenCalculatingCacheSizes {
@Test
void givenInOkRange_thenCalcSizeCorrectly() {
sut.maxMemorySupplier = () -> 400_000_000L;
assertThat(sut.calcCacheSize()).isEqualTo(250_000_000L);
sut.maxMemorySupplier = () -> 40_000_000L + 150_000_000L;
assertThat(sut.calcCacheSize()).isEqualTo(40_000_000L);
}

@Test
Expand All @@ -210,29 +210,9 @@ void givenBelowLimit_thenReturnLowerLimit() {
@Test
void givenAboveLimit_thenReturnUpperLimit() {
sut.maxMemorySupplier = () -> 3_000_000_000L;
assertThat(sut.calcCacheSize()).isEqualTo(1_500_000_000L);
assertThat(sut.calcCacheSize()).isEqualTo(100_000_000L);
}
}

// @Nested
// @DisplayName("when calculating jdbc url")
// class WhenCalculatingJdbcUrl {
// @ParameterizedTest
// @ValueSource(strings = {"../test.url/location", "/home/x", "./data/calc"})
// void whenDatabaseLocationIsInserted_thenEnsureItsInTheUrl(String location) {
// when(config.dbLocation()).thenReturn(Optional.of(location));
// assertThat(sut.calcJdbcUrl(0)).startsWith("jdbc:h2:" + location + ";");
// }
//
// @ParameterizedTest
// @ValueSource(longs = {1L, 1_000_000L, 5_000_000_000L})
// void whenCacheSizeIsInserted_thenEnsureItsInTheUrl(long cacheSize) {
// var cacheSizeKb = cacheSize / 1024;
// when(config.dbLocation()).thenReturn(Optional.empty());
// assertThat(sut.calcJdbcUrl(cacheSize))
// .contains(";CACHE_SIZE=" + cacheSizeKb);
// }
// }
}

private ClipEntry createClip(String channel, String show, String title, int daysBefore) {
Expand Down

0 comments on commit 6f4f529

Please sign in to comment.