Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ composeMultiplatform = "1.11.0"
kotlinx-coroutines = "1.11.0"
kotlinx-serialization-json = "1.11.0"
ktor = "3.5.0"
material3 = "1.10.0-alpha05"
material3 = "1.9.0"
iconsExtended = "1.7.3"
koin = "4.2.1"

Expand All @@ -30,7 +30,7 @@ preferences-core = "1.2.1"
filekit = "0.14.1"
htmlconverter = "1.1.1"
foundation = "1.11.2"
oshi-core = "7.1.0"
oshi-core = "7.2.1"

logger = "3.0.3"
foreground = "0.1.0"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ class PushTargetTranslation(

return repository?.let {
push(repo, repository.sshUrl, onProgress)
} ?: Result(Status.UNKNOWN, "Failed to get repository ${targetTranslation.id}")
} ?: Result(Status.UNKNOWN, null)

} catch (e: Exception) {
Logger.e(TAG, "Failed to push target translation", e)
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class AdvancedGogsRepoSearchTest : BaseIntegrationTest() {
}

@Test
fun searchReposByUser() = runBlocking {
fun searchReposByUser() {
val user = "test"

server.enqueue(createUsersResponse())
Expand All @@ -37,53 +37,53 @@ class AdvancedGogsRepoSearchTest : BaseIntegrationTest() {
val onProgress: (Float, String?) -> Unit = { _, message ->
progressMessage = message
}
val repos = advancedGogsRepoSearch.execute(user, "", 5, onProgress)
val repos = runBlocking { advancedGogsRepoSearch.execute(user, "", 5, onProgress) }

assertTrue(repos.isNotEmpty())
assertFalse(progressMessage.isNullOrEmpty())
}

@Test
fun searchReposByRepoName() = runBlocking {
fun searchReposByRepoName() {
val repo = "_gen_"

server.enqueue(createReposResponse())
server.enqueue(createRepoResponse())

val repos = advancedGogsRepoSearch.execute("", repo, 5)
val repos = runBlocking { advancedGogsRepoSearch.execute("", repo, 5) }
assertTrue(repos.isNotEmpty())
}

@Test
fun searchReposByUserAndRepoName() = runBlocking {
fun searchReposByUserAndRepoName() {
val user = "mxaln"
val repo = "_gen_"

server.enqueue(createUsersResponse())
server.enqueue(createReposResponse())
server.enqueue(createRepoResponse())

val repos = advancedGogsRepoSearch.execute(user, repo, 5)
val repos = runBlocking { advancedGogsRepoSearch.execute(user, repo, 5) }
assertTrue(repos.isNotEmpty())
}

@Test
fun searchNonExistentUser() = runBlocking {
fun searchNonExistentUser() {
val user = "non-existent-user"

server.enqueue(createEmptyDataResponse())

val repos = advancedGogsRepoSearch.execute(user, "", 5)
val repos = runBlocking { advancedGogsRepoSearch.execute(user, "", 5) }
assertTrue(repos.isEmpty())
}

@Test
fun searchNonExistentRepo() = runBlocking {
fun searchNonExistentRepo() {
val repo = "non-existent-repo"

server.enqueue(createEmptyDataResponse())

val repos = advancedGogsRepoSearch.execute("", repo, 5)
val repos = runBlocking { advancedGogsRepoSearch.execute("", repo, 5) }
assertTrue(repos.isEmpty())
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package org.bibletranslationtools.writer.integration.usecases

import kotlinx.coroutines.test.runTest
import kotlinx.coroutines.runBlocking
import org.bibletranslationtools.writer.BaseIntegrationTest
import org.bibletranslationtools.writer.Platform
import org.bibletranslationtools.writer.usecases.CheckForLatestRelease
Expand All @@ -16,8 +16,8 @@ class CheckForLatestReleaseTest : BaseIntegrationTest() {
private val platform: Platform by inject()

@Test
fun checkForLatestRelease() = runTest {
val result = checkForLatestRelease.execute()
fun checkForLatestRelease() {
val result = runBlocking { checkForLatestRelease.execute() }

if (result.release != null) {
assertFalse(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package org.bibletranslationtools.writer.integration.usecases

import kotlinx.coroutines.test.runTest
import kotlinx.coroutines.runBlocking
import org.bibletranslationtools.writer.BaseIntegrationTest
import org.bibletranslationtools.writer.usecases.CloneRepository
import org.junit.Assert.assertEquals
Expand All @@ -16,14 +16,14 @@ class CloneRepositoryTest : BaseIntegrationTest() {
private val cloneRepository: CloneRepository by inject()

@Test
fun cloneRepositorySuccessfully() = runTest {
fun cloneRepositorySuccessfully() {
val cloneUrl = "https://wacs.bibletranslationtools.org/WycliffeAssociates/en_ulb.git"
var progressMessage: String? = null
val onProgress: (Float, String?) -> Unit = { _, message ->
progressMessage = message
}

val result = cloneRepository.execute(cloneUrl, onProgress)
val result = runBlocking { cloneRepository.execute(cloneUrl, onProgress) }

assertNotNull("Clone repository result should not be null", result)
assertNotNull("Progress message should not be null", progressMessage)
Expand All @@ -40,15 +40,15 @@ class CloneRepositoryTest : BaseIntegrationTest() {
}

@Test
fun cloneNonExistingRepositoryFailed() = runTest {
fun cloneNonExistingRepositoryFailed() {
val cloneUrl = "https://wacs.bibletranslationtools.org/WycliffeAssociates/non_existing_repo.git"

var progressMessage: String? = null
val onProgress: (Float, String?) -> Unit = { _, message ->
progressMessage = message
}

val result = cloneRepository.execute(cloneUrl, onProgress)
val result = runBlocking { cloneRepository.execute(cloneUrl, onProgress) }

assertNotNull("Clone repository result should not be null", result)
assertNotNull("Progress message should not be null", progressMessage)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,60 +62,57 @@ class CreateRepositoryTest : BaseIntegrationTest() {
}

@Test
fun createRepositoryWithAuthenticationSucceeds() = runBlocking {
fun createRepositoryWithAuthenticationSucceeds() {
loginGogsUser()

createRepoResponse(201)

val created = createRepository.execute(targetTranslation)
val created = runBlocking { createRepository.execute(targetTranslation) }

assertTrue("Repository should be created when authenticated", created)
}

@Test
fun createRepositoryThatAlreadyExistsSucceeds() = runBlocking {
fun createRepositoryThatAlreadyExistsSucceeds() {
loginGogsUser()

createRepoResponse(409)

val created = createRepository.execute(targetTranslation)
val created = runBlocking { createRepository.execute(targetTranslation) }

assertTrue("Repository should be created when authenticated", created)
}

@Test
fun createRepositoryServerError() = runBlocking {
fun createRepositoryServerError() {
loginGogsUser()

createRepoResponse(500)

val created = createRepository.execute(targetTranslation)
val created = runBlocking { createRepository.execute(targetTranslation) }

assertFalse("Repository should not be created", created)
}

@Test
fun createRepositoryWithoutAuthenticationFails() = runBlocking {
fun createRepositoryWithoutAuthenticationFails() {
var progressMessage: String? = null
val onProgress: (Float, String?) -> Unit = { _, message ->
progressMessage = message
}

createRepoResponse(403)

val created = createRepository.execute(targetTranslation, onProgress)
val created = runBlocking { createRepository.execute(targetTranslation, onProgress) }

assertFalse("Repository should not be created when not authenticated", created)
assertNotNull("Progress message should not be null", progressMessage)
}

private fun loginGogsUser() = runBlocking{
profile.gogsUser = TestUtils.simulateLoginGogsUser(
platform,
server,
gogsLogin,
"test"
)
private fun loginGogsUser() {
profile.gogsUser = runBlocking {
TestUtils.simulateLoginGogsUser(platform, server, gogsLogin, "test")
}
}

private fun createRepoResponse(responseCode: Int) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class DownloadIndexTest : BaseIntegrationTest() {
}

@Test
fun downloadIndexSucceeds() = runBlocking {
fun downloadIndexSucceeds() {
var progressMessage: String? = null
val onProgress: (Float, String?) -> Unit = { _, message ->
progressMessage = message
Expand All @@ -44,7 +44,7 @@ class DownloadIndexTest : BaseIntegrationTest() {
}
assertTrue("Languages before should not be empty", languagesBefore.isNotEmpty())

val downloaded = downloadIndex.download(onProgress)
val downloaded = runBlocking { downloadIndex.download(onProgress) }

assertTrue("Download result should be true", downloaded)
assertNotNull("Progress message should not be null", progressMessage)
Expand All @@ -63,18 +63,18 @@ class DownloadIndexTest : BaseIntegrationTest() {
}

@Test
fun importIndexSucceeds() = runBlocking {
fun importIndexSucceeds() {
val languagesBefore = catalogClient.library.getTargetLanguages()
assertTrue("Languages before should not be empty", languagesBefore.isNotEmpty())

val indexFile = directoryProvider.createTempFile("index", ".sqlite")
val indexFile = runBlocking { directoryProvider.createTempFile("index", ".sqlite") }
directoryProvider.databaseFile.inputStream().use { input ->
indexFile.outputStream().use { output ->
input.copyTo(output)
}
}

val imported = downloadIndex.import(PlatformFile(indexFile))
val imported = runBlocking { downloadIndex.import(PlatformFile(indexFile)) }

assertTrue("Import result should be true", imported)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,9 +117,9 @@ class DownloadResourceContainersTest : BaseIntegrationTest() {
}

@Test
fun downloadIncorrectResourceContainers() = runTest {
fun downloadIncorrectResourceContainers() {
val badTranslationIds = listOf("bad_tr_id1", "bad_tr_id2")
val result = downloadResourceContainers.download(badTranslationIds)
val result = runBlocking { downloadResourceContainers.download(badTranslationIds) }

assertNotNull("Download result should not be null", result)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,41 +61,38 @@ class GetRepositoryTest : BaseIntegrationTest() {
}

@Test
fun getRepositorySucceeds() = runBlocking {
fun getRepositorySucceeds() {
loginGogsUser()
processRepoResponse(targetTranslation.id)

val repo = getRepository.execute(targetTranslation)
val repo = runBlocking { getRepository.execute(targetTranslation) }

assertNotNull("Repository should not be null", repo)

assertEquals(targetTranslation.id, repo!!.name)
}

@Test
fun getRepositoryThatIsNotExactNameFails() = runBlocking {
fun getRepositoryThatIsNotExactNameFails() {
loginGogsUser()
processRepoResponse("${targetTranslation.id}_L3")

val repo = getRepository.execute(targetTranslation)
val repo = runBlocking { getRepository.execute(targetTranslation) }

assertNull("Repository should be null", repo)
}

@Test
fun getRepositoryNotAuthorizedFails() = runBlocking {
val repo = getRepository.execute(targetTranslation)
fun getRepositoryNotAuthorizedFails() {
val repo = runBlocking { getRepository.execute(targetTranslation) }

assertNull("Repository should be null", repo)
}

private fun loginGogsUser() = runBlocking {
profile.gogsUser = TestUtils.simulateLoginGogsUser(
platform,
server,
gogsLogin,
"test"
)
private fun loginGogsUser() {
profile.gogsUser = runBlocking {
TestUtils.simulateLoginGogsUser(platform, server, gogsLogin, "test")
}
}

private fun processRepoResponse(id: String) {
Expand Down
Loading
Loading