diff --git a/android/app/src/test/java/com/fabledsword/minstrel/api/AuthCookieInterceptorTest.kt b/android/app/src/test/java/com/fabledsword/minstrel/api/AuthCookieInterceptorTest.kt index f93a9ac0..7f1455e8 100644 --- a/android/app/src/test/java/com/fabledsword/minstrel/api/AuthCookieInterceptorTest.kt +++ b/android/app/src/test/java/com/fabledsword/minstrel/api/AuthCookieInterceptorTest.kt @@ -4,6 +4,7 @@ import com.fabledsword.minstrel.auth.AuthStore import com.fabledsword.minstrel.auth.FakeSessionVault import com.fabledsword.minstrel.auth.SessionVault import com.fabledsword.minstrel.cache.db.dao.AuthSessionDao +import com.fabledsword.minstrel.cache.db.entities.AuthSessionEntity import io.mockk.coEvery import io.mockk.every import io.mockk.mockk @@ -155,16 +156,19 @@ class AuthCookieInterceptorTest { override fun write(value: String?): Boolean = true } + // The store runs on a real background dispatcher here, so its row + // collector lands after construction; the row itself carries the + // server URL so that collector cannot reset it to the default. + val row = AuthSessionEntity(baseUrl = server.url("/").toString()) val dao = mockk { - every { observe() } returns flowOf(null) - coEvery { get() } returns null + every { observe() } returns flowOf(row) + coEvery { get() } returns row coEvery { upsert(any()) } returns Unit coEvery { setSessionCookie(any()) } returns Unit coEvery { setBaseUrl(any()) } returns Unit } val loading = AuthStore(dao, slowVault, CoroutineScope(SupervisorJob() + Dispatchers.Default)) - loading.setBaseUrl(server.url("/").toString()) val launchClient = OkHttpClient.Builder() .addInterceptor(AuthCookieInterceptor(loading))