mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-07 20:31:06 -05:00
Update SqliteDBStoreTest with swap/compression
This commit is contained in:
parent
961cec5bc8
commit
c67014b859
1 changed files with 19 additions and 6 deletions
|
@ -69,10 +69,23 @@ public class SqliteDBStoreTest {
|
||||||
assertEquals("asdf", dbStore.getOldestUnswappedProject());
|
assertEquals("asdf", dbStore.getOldestUnswappedProject());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void swapAndRestore() {
|
||||||
|
String projectName = "something";
|
||||||
|
String compression = "bzip2";
|
||||||
|
dbStore.setLatestVersionForProject(projectName, 42);
|
||||||
|
dbStore.swap(projectName, compression);
|
||||||
|
assertNull(dbStore.getOldestUnswappedProject());
|
||||||
|
assertEquals(dbStore.getSwapCompression(projectName), compression);
|
||||||
|
// and restore
|
||||||
|
dbStore.restore(projectName);
|
||||||
|
assertEquals(dbStore.getSwapCompression(projectName), null);
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void noOldestProjectIfAllEvicted() {
|
public void noOldestProjectIfAllEvicted() {
|
||||||
dbStore.setLatestVersionForProject("older", 3);
|
dbStore.setLatestVersionForProject("older", 3);
|
||||||
dbStore.setLastAccessedTime("older", null);
|
dbStore.swap("older", "bzip2");
|
||||||
assertNull(dbStore.getOldestUnswappedProject());
|
assertNull(dbStore.getOldestUnswappedProject());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -93,7 +106,7 @@ public class SqliteDBStoreTest {
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
assertEquals("older", dbStore.getOldestUnswappedProject());
|
assertEquals("older", dbStore.getOldestUnswappedProject());
|
||||||
dbStore.setLastAccessedTime("older", null);
|
dbStore.swap("older", "bzip2");
|
||||||
assertEquals("newer", dbStore.getOldestUnswappedProject());
|
assertEquals("newer", dbStore.getOldestUnswappedProject());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -115,9 +128,9 @@ public class SqliteDBStoreTest {
|
||||||
Timestamp.valueOf(LocalDateTime.now())
|
Timestamp.valueOf(LocalDateTime.now())
|
||||||
);
|
);
|
||||||
assertEquals(1, dbStore.getNumUnswappedProjects());
|
assertEquals(1, dbStore.getNumUnswappedProjects());
|
||||||
dbStore.setLastAccessedTime(
|
dbStore.swap(
|
||||||
"asdf",
|
"asdf",
|
||||||
null
|
"bzip2"
|
||||||
);
|
);
|
||||||
assertEquals(0, dbStore.getNumUnswappedProjects());
|
assertEquals(0, dbStore.getNumUnswappedProjects());
|
||||||
}
|
}
|
||||||
|
@ -143,7 +156,7 @@ public class SqliteDBStoreTest {
|
||||||
@Test
|
@Test
|
||||||
public void projectStateIsSwappedIfLastAccessedIsNull() {
|
public void projectStateIsSwappedIfLastAccessedIsNull() {
|
||||||
dbStore.setLatestVersionForProject("asdf", 1);
|
dbStore.setLatestVersionForProject("asdf", 1);
|
||||||
dbStore.setLastAccessedTime("asdf", null);
|
dbStore.swap("asdf", "bzip2");
|
||||||
assertEquals(ProjectState.SWAPPED, dbStore.getProjectState("asdf"));
|
assertEquals(ProjectState.SWAPPED, dbStore.getProjectState("asdf"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue