Fix tests

This commit is contained in:
Faierbel 2024-04-14 02:57:05 +02:00
parent 6616a313e2
commit 985be92a4d

View File

@ -50,7 +50,7 @@ class SemesterRepositoryTest {
getSemesterPojo(1, 2, now().minusMonths(3), now()) getSemesterPojo(1, 2, now().minusMonths(3), now())
) )
coEvery { semesterDb.loadAll(student.studentId, student.classId) } returns emptyList() coEvery { semesterDb.loadAll(student) } returns emptyList()
coEvery { sdk.getSemesters() } returns semesters coEvery { sdk.getSemesters() } returns semesters
coEvery { semesterDb.removeOldAndSaveNew(any(), any()) } just Runs coEvery { semesterDb.removeOldAndSaveNew(any(), any()) } just Runs
@ -76,12 +76,7 @@ class SemesterRepositoryTest {
getSemesterPojo(123, 2, now().minusMonths(3), now()) getSemesterPojo(123, 2, now().minusMonths(3), now())
) )
coEvery { coEvery { semesterDb.loadAll(student) } returns badSemesters.mapToEntities(student.studentId)
semesterDb.loadAll(
student.studentId,
student.classId
)
} returns badSemesters.mapToEntities(student.studentId)
coEvery { sdk.getSemesters() } returns goodSemesters coEvery { sdk.getSemesters() } returns goodSemesters
coEvery { semesterDb.removeOldAndSaveNew(any(), any()) } just Runs coEvery { semesterDb.removeOldAndSaveNew(any(), any()) } just Runs
@ -103,7 +98,7 @@ class SemesterRepositoryTest {
getSemesterPojo(2, 3, now(), now().plusMonths(6)), getSemesterPojo(2, 3, now(), now().plusMonths(6)),
) )
coEvery { semesterDb.loadAll(student.studentId, student.classId) } returnsMany listOf( coEvery { semesterDb.loadAll(any()) } returnsMany listOf(
badSemesters.mapToEntities(student.studentId), badSemesters.mapToEntities(student.studentId),
badSemesters.mapToEntities(student.studentId), badSemesters.mapToEntities(student.studentId),
goodSemesters.mapToEntities(student.studentId) goodSemesters.mapToEntities(student.studentId)
@ -125,7 +120,7 @@ class SemesterRepositoryTest {
getSemesterEntity(1, 2, now().minusMonths(6), now().minusMonths(1)) getSemesterEntity(1, 2, now().minusMonths(6), now().minusMonths(1))
) )
coEvery { semesterDb.loadAll(student.studentId, student.classId) } returns semesters coEvery { semesterDb.loadAll(student) } returns semesters
val items = runBlocking { semesterRepository.getSemesters(student) } val items = runBlocking { semesterRepository.getSemesters(student) }
assertEquals(2, items.size) assertEquals(2, items.size)
@ -138,7 +133,7 @@ class SemesterRepositoryTest {
getSemesterEntity(1, 2, now().minusMonths(3), now()) getSemesterEntity(1, 2, now().minusMonths(3), now())
) )
coEvery { semesterDb.loadAll(student.studentId, student.classId) } returns semesters coEvery { semesterDb.loadAll(student) } returns semesters
val items = runBlocking { semesterRepository.getSemesters(student) } val items = runBlocking { semesterRepository.getSemesters(student) }
assertEquals(2, items.size) assertEquals(2, items.size)
@ -151,7 +146,7 @@ class SemesterRepositoryTest {
getSemesterEntity(1, 2, now(), now()) getSemesterEntity(1, 2, now(), now())
) )
coEvery { semesterDb.loadAll(student.studentId, student.classId) } returns semesters coEvery { semesterDb.loadAll(student) } returns semesters
val items = runBlocking { semesterRepository.getSemesters(student) } val items = runBlocking { semesterRepository.getSemesters(student) }
assertEquals(2, items.size) assertEquals(2, items.size)
@ -164,7 +159,7 @@ class SemesterRepositoryTest {
getSemesterPojo(1, 2, now().minusMonths(3), now()) getSemesterPojo(1, 2, now().minusMonths(3), now())
) )
coEvery { semesterDb.loadAll(student.studentId, student.classId) } returns emptyList() coEvery { semesterDb.loadAll(student) } returns emptyList()
coEvery { sdk.getSemesters() } returns semesters coEvery { sdk.getSemesters() } returns semesters
coEvery { semesterDb.removeOldAndSaveNew(any(), any()) } just Runs coEvery { semesterDb.removeOldAndSaveNew(any(), any()) } just Runs
@ -193,12 +188,7 @@ class SemesterRepositoryTest {
getSemesterPojo(2, 2, now().plusMonths(5), now().plusMonths(11)), getSemesterPojo(2, 2, now().plusMonths(5), now().plusMonths(11)),
) )
coEvery { coEvery { semesterDb.loadAll(student) } returns semestersWithNoCurrent
semesterDb.loadAll(
student.studentId,
student.classId
)
} returns semestersWithNoCurrent
coEvery { sdk.getSemesters() } returns newSemesters coEvery { sdk.getSemesters() } returns newSemesters
coEvery { semesterDb.removeOldAndSaveNew(any(), any()) } just Runs coEvery { semesterDb.removeOldAndSaveNew(any(), any()) } just Runs
@ -214,7 +204,7 @@ class SemesterRepositoryTest {
getSemesterEntity(1, 2, now().minusMonths(1), now().plusMonths(1)) getSemesterEntity(1, 2, now().minusMonths(1), now().plusMonths(1))
) )
coEvery { semesterDb.loadAll(student.studentId, student.classId) } returns semesters coEvery { semesterDb.loadAll(student) } returns semesters
val items = semesterRepository.getSemesters(student, refreshOnNoCurrent = true) val items = semesterRepository.getSemesters(student, refreshOnNoCurrent = true)
assertEquals(2, items.size) assertEquals(2, items.size)
@ -227,14 +217,14 @@ class SemesterRepositoryTest {
getSemesterEntity(1, 1, now(), now()) getSemesterEntity(1, 1, now(), now())
) )
coEvery { semesterDb.loadAll(student.studentId, student.classId) } returns semesters coEvery { semesterDb.loadAll(student) } returns semesters
runBlocking { semesterRepository.getCurrentSemester(student) } runBlocking { semesterRepository.getCurrentSemester(student) }
} }
@Test(expected = RuntimeException::class) @Test(expected = RuntimeException::class)
fun getCurrentSemester_emptyList() { fun getCurrentSemester_emptyList() {
coEvery { semesterDb.loadAll(student.studentId, student.classId) } returns emptyList() coEvery { semesterDb.loadAll(student) } returns emptyList()
coEvery { sdk.getSemesters() } returns emptyList() coEvery { sdk.getSemesters() } returns emptyList()
runBlocking { semesterRepository.getCurrentSemester(student) } runBlocking { semesterRepository.getCurrentSemester(student) }