package pl.firmatpp.kierowca.data.upload

import org.junit.Assert.assertFalse
import org.junit.Assert.assertTrue
import org.junit.Test
import pl.firmatpp.kierowca.data.ApiErrorKind

class RoutePointWorkerRulesTest {
    @Test
    fun inactiveRouteConflictDiscardsObsoleteGpsPoints() {
        assertTrue(isInactiveRoutePointError("ROUTE_POINTS_INVALID_STATUS"))
    }

    @Test
    fun temporaryServerFailureDoesNotDiscardGpsPoints() {
        assertFalse(isInactiveRoutePointError("SERVER_UNAVAILABLE"))
        assertFalse(isInactiveRoutePointError(null))
    }

    @Test
    fun revokedSessionStopsRouteTracking() {
        assertTrue(shouldStopRouteTrackingAfterPointError(ApiErrorKind.Auth, null))
    }

    @Test
    fun temporaryFailureKeepsRouteTrackingActive() {
        assertFalse(shouldStopRouteTrackingAfterPointError(ApiErrorKind.Server, "SERVER_UNAVAILABLE"))
    }
}
