Skip to content
Snippets Groups Projects
Commit 53f05e50 authored by Sebastian's avatar Sebastian
Browse files

Use @TempDir instead of /tmp in WebServerIntegrationTest

parent 330860bf
No related branches found
No related tags found
1 merge request!16Basic database setup
Pipeline #7519 passed
......@@ -21,7 +21,7 @@ import javax.inject.Singleton
]
)
@InstallIn(SingletonComponent::class)
internal class TestModule {
internal class TestModule(private val tempDir: File) {
@Singleton
@Provides
fun provideClock() = Clock { System.currentTimeMillis() }
......@@ -30,7 +30,7 @@ internal class TestModule {
@Provides
fun provideDatabaseConfig() = object : DatabaseConfig {
override fun getDatabaseDirectory(): File {
return File("/tmp")
return tempDir
}
}
}
......@@ -7,26 +7,31 @@ import io.ktor.client.statement.HttpResponse
import io.ktor.client.statement.readText
import kotlinx.coroutines.runBlocking
import org.briarproject.mailbox.core.DaggerTestComponent
import org.briarproject.mailbox.core.TestComponent
import org.briarproject.mailbox.core.TestModule
import org.briarproject.mailbox.core.server.WebServerManager.Companion.PORT
import org.junit.jupiter.api.AfterAll
import org.junit.jupiter.api.BeforeAll
import org.junit.jupiter.api.Test
import org.junit.jupiter.api.TestInstance
import org.junit.jupiter.api.TestInstance.Lifecycle
import org.junit.jupiter.api.io.TempDir
import java.io.File
import kotlin.test.assertEquals
@TestInstance(Lifecycle.PER_CLASS)
class WebServerIntegrationTest {
private val testComponent = DaggerTestComponent.builder().build()
private val lifecycleManager = testComponent.getLifecycleManager()
private lateinit var testComponent: TestComponent
private val lifecycleManager by lazy { testComponent.getLifecycleManager() }
private val httpClient = HttpClient(CIO) {
expectSuccess = false // prevents exceptions on non-success responses
}
private val baseUrl = "http://127.0.0.1:$PORT"
@BeforeAll
fun setUp() {
fun setUp(@TempDir tempDir: File) {
testComponent = DaggerTestComponent.builder().testModule(TestModule(tempDir)).build()
testComponent.injectCoreEagerSingletons()
lifecycleManager.startServices()
lifecycleManager.waitForStartup()
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment