[db] Add plumping for fetching and adding a new repo

This commit is contained in:
Torsten Grote
2023-06-23 18:14:30 -03:00
parent 937fe99062
commit f3e8a0a45b
18 changed files with 1640 additions and 1 deletions

View File

@@ -152,6 +152,21 @@ internal class RepositoryDaoTest : DbTest() {
assertEquals(0, repoDao.getLiveRepositories().getOrFail().size)
}
@Test
fun testGetRepositoryByCert() {
val cert = getRandomString()
// insert repo and (required) preferences
val repo1 = getRandomRepo().toCoreRepository(version = 42L, certificate = cert)
val repoId = repoDao.insertOrReplace(repo1)
val repositoryPreferences = RepositoryPreferences(repoId, 3)
repoDao.insert(repositoryPreferences)
// repo is returned when querying for right cert
assertEquals(repo1.copy(repoId = repoId), repoDao.getRepository(cert)?.repository)
// nothing is returned when querying for non-existent cert
assertNull(repoDao.getRepository("foo bar"))
}
@Test
fun testSetRepositoryEnabled() {
// repo is enabled by default