fix(test): pass accountRepository to DiagnosticsCollector in CrashReporterInstallTest
DiagnosticsCollector gained a 4th constructor param (accountRepository) for the PII-free account summary, but CrashReporterInstallTest still constructed it with 3 args — a compile error that broke the Unit tests and Static analysis gates. Add the AccountRepository mock with observeAccounts() stubbed to an empty flow (matching DiagnosticsCollectorTest) and pass it to both call sites. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -4,12 +4,14 @@ package org.libremail.reporting
|
||||
import io.mockk.every
|
||||
import io.mockk.mockk
|
||||
import io.mockk.verify
|
||||
import kotlinx.coroutines.flow.flowOf
|
||||
import org.junit.After
|
||||
import org.junit.Before
|
||||
import org.junit.Rule
|
||||
import org.junit.Test
|
||||
import org.junit.rules.TemporaryFolder
|
||||
import org.libremail.data.settings.SettingsRepository
|
||||
import org.libremail.domain.repository.AccountRepository
|
||||
import kotlin.test.assertEquals
|
||||
import kotlin.test.assertTrue
|
||||
|
||||
@@ -30,6 +32,9 @@ class CrashReporterInstallTest {
|
||||
every { versionCode } returns 1L
|
||||
}
|
||||
private val settingsRepository = mockk<SettingsRepository>()
|
||||
private val accountRepository = mockk<AccountRepository> {
|
||||
every { observeAccounts() } returns flowOf(emptyList())
|
||||
}
|
||||
|
||||
private var original: Thread.UncaughtExceptionHandler? = null
|
||||
|
||||
@@ -49,7 +54,7 @@ class CrashReporterInstallTest {
|
||||
Thread.setDefaultUncaughtExceptionHandler(previous)
|
||||
val store = ReportStore(tempFolder.root)
|
||||
val buffer = RingLogBuffer()
|
||||
val collector = DiagnosticsCollector(appVersion, settingsRepository, buffer)
|
||||
val collector = DiagnosticsCollector(appVersion, settingsRepository, accountRepository, buffer)
|
||||
val reporter = CrashReporter(collector, store, buffer)
|
||||
|
||||
reporter.install()
|
||||
@@ -70,7 +75,7 @@ class CrashReporterInstallTest {
|
||||
Thread.setDefaultUncaughtExceptionHandler(mockk(relaxed = true))
|
||||
val store = ReportStore(tempFolder.root)
|
||||
val buffer = RingLogBuffer()
|
||||
val collector = DiagnosticsCollector(appVersion, settingsRepository, buffer)
|
||||
val collector = DiagnosticsCollector(appVersion, settingsRepository, accountRepository, buffer)
|
||||
val reporter = CrashReporter(collector, store, buffer)
|
||||
reporter.install()
|
||||
val installed = requireNotNull(Thread.getDefaultUncaughtExceptionHandler())
|
||||
|
||||
Reference in New Issue
Block a user