From 5ad90115ffadfe94fec07ffa7e244ddeaa5801d9 Mon Sep 17 00:00:00 2001 From: Claude Date: Mon, 21 Sep 2026 20:15:50 +0000 Subject: [PATCH] fix: opt in to ExperimentalCoroutinesApi in calendar ViewModel tests `Dispatchers.setMain`/`resetMain` from kotlinx-coroutines-test are marked `@ExperimentalCoroutinesApi`, so the `@Before`/`@After` blocks in both calendar ViewModel tests emitted four "This declaration needs opt-in" warnings on every `:amethyst:compileFdroidDebugUnitTestKotlin`. Add a class-level `@OptIn(ExperimentalCoroutinesApi::class)`, matching what `NestViewModelTest` and `PollResultsViewModelTest` in `commons` already do for the same helpers. Co-Authored-By: Claude Opus 5 Claude-Session: https://claude.ai/code/session_01RQSCURwPmwVfGR9Gard5JY --- .../amethyst/calendar/CalendarsViewModelFlowTest.kt | 2 ++ .../vitorpamplona/amethyst/calendar/CalendarsViewModelTest.kt | 2 ++ 2 files changed, 4 insertions(+) diff --git a/amethyst/src/test/java/com/vitorpamplona/amethyst/calendar/CalendarsViewModelFlowTest.kt b/amethyst/src/test/java/com/vitorpamplona/amethyst/calendar/CalendarsViewModelFlowTest.kt index 1c05b77857..173db7e738 100644 --- a/amethyst/src/test/java/com/vitorpamplona/amethyst/calendar/CalendarsViewModelFlowTest.kt +++ b/amethyst/src/test/java/com/vitorpamplona/amethyst/calendar/CalendarsViewModelFlowTest.kt @@ -32,6 +32,7 @@ import com.vitorpamplona.quartz.nip52Calendar.appt.time.CalendarTimeSlotEvent import com.vitorpamplona.quartz.nip52Calendar.calendar.CalendarEvent import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.Dispatchers +import kotlinx.coroutines.ExperimentalCoroutinesApi import kotlinx.coroutines.SupervisorJob import kotlinx.coroutines.cancel import kotlinx.coroutines.flow.StateFlow @@ -65,6 +66,7 @@ import org.junit.Test * `LocalCache` is a process-wide object and JUnit's method order is hash-based, so every method * uses its own author key and asserts only over that key's events. */ +@OptIn(ExperimentalCoroutinesApi::class) class CalendarsViewModelFlowTest { // viewModelScope is Dispatchers.Main, and every flow is a WhileSubscribed stateIn, so nothing // runs until something subscribes. diff --git a/amethyst/src/test/java/com/vitorpamplona/amethyst/calendar/CalendarsViewModelTest.kt b/amethyst/src/test/java/com/vitorpamplona/amethyst/calendar/CalendarsViewModelTest.kt index 389b3ef5aa..770e0add94 100644 --- a/amethyst/src/test/java/com/vitorpamplona/amethyst/calendar/CalendarsViewModelTest.kt +++ b/amethyst/src/test/java/com/vitorpamplona/amethyst/calendar/CalendarsViewModelTest.kt @@ -26,6 +26,7 @@ import com.vitorpamplona.amethyst.ui.screen.loggedIn.calendars.CalendarsViewMode import com.vitorpamplona.amethyst.ui.screen.loggedIn.calendars.CalendarsViewModel import com.vitorpamplona.amethyst.ui.screen.loggedIn.calendars.startOfWeek import kotlinx.coroutines.Dispatchers +import kotlinx.coroutines.ExperimentalCoroutinesApi import kotlinx.coroutines.test.resetMain import kotlinx.coroutines.test.setMain import org.junit.After @@ -41,6 +42,7 @@ import java.time.YearMonth * The paging arithmetic the calendar lenses share, now that it lives on the screen's ViewModel * instead of being spelled out in each view's click handlers. */ +@OptIn(ExperimentalCoroutinesApi::class) class CalendarsViewModelTest { // The model's derived flows are `stateIn(viewModelScope, …)`, and stateIn launches its // sharing coroutine as soon as the property initializer runs — so simply CONSTRUCTING the