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 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01RQSCURwPmwVfGR9Gard5JY
This commit is contained in:
Claude
2026-09-21 20:15:50 +00:00
parent 6d3dd72801
commit 5ad90115ff
2 changed files with 4 additions and 0 deletions
@@ -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.
@@ -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