package com.cottondb.albums import androidx.work.WorkInfo.State import com.cottondb.albums.analysis.PassStart import com.cottondb.albums.analysis.PassStart.Act import com.cottondb.albums.analysis.PassStart.Line import org.junit.Assert.assertEquals import org.junit.Test /** * The hard walk (27 Nov 2026): a first pass killed with its process (kill -9 in front, force-stop) waited out the * system's backoff, 30 s doubling at each stop, while its band said "Paused ยท waiting for the charger". With Albums * open it carries on now, from what is written; the band says waiting for the charger only when the pass asks for it. */ class PassStartTest { @Test fun a_first_pass_stopped_part_way_runs_now_when_albums_is_open() { assertEquals(Act.RunNow, PassStart.act(paused = false, firstDone = false, state = State.ENQUEUED, attempts = 1, needsCharger = false)) assertEquals(Act.RunNow, PassStart.act(paused = false, firstDone = false, state = State.ENQUEUED, attempts = 4, needsCharger = false)) } @Test fun a_new_running_paused_or_later_pass_is_left_as_it_is() { assertEquals("just queued, never ran: it starts by itself", Act.Keep, PassStart.act(false, false, State.ENQUEUED, 0, false)) assertEquals("looking now", Act.Nothing, PassStart.act(false, false, State.RUNNING, 1, false)) assertEquals("paused by him: never by itself", Act.Nothing, PassStart.act(true, false, State.ENQUEUED, 3, false)) assertEquals("a later pass waits for the charger", Act.Keep, PassStart.act(false, true, State.ENQUEUED, 2, true)) assertEquals("the first pass handed to a later one (6 h a day) waits for the charger", Act.Keep, PassStart.act(false, false, State.ENQUEUED, 2, true)) assertEquals("nothing queued: ensured", Act.Keep, PassStart.act(false, false, null, 0, false)) } @Test fun the_band_says_waiting_for_the_charger_only_when_the_pass_asks_for_it() { assertEquals(Line.Starting, PassStart.line(paused = false, state = State.ENQUEUED, needsCharger = false)) assertEquals(Line.Charger, PassStart.line(paused = false, state = State.ENQUEUED, needsCharger = true)) assertEquals(Line.Running, PassStart.line(paused = false, state = State.RUNNING, needsCharger = false)) assertEquals(Line.Paused, PassStart.line(paused = true, state = State.ENQUEUED, needsCharger = false)) assertEquals(Line.Starting, PassStart.line(paused = false, state = null, needsCharger = false)) } }