fix: address final review findings for provider migration
- Add SessionCoordinator regression test covering switch from an authenticated ABox profile to Local experience: remote session is logged out and cleared, only Local is the active/observable session, credentials are cleared, auto-login disabled, and gateway state stays isolated (verified to fail when switch cleanup is removed). - Replace if/else provider dispatch with exhaustive when over ProviderType in all three routing gateways so future enum additions fail compilation. - Silence the known ExperimentalCoroutinesApi opt-in warning in ProviderSelectionViewModelTest with a class-level @OptIn.
This commit is contained in:
+12
-6
@@ -71,8 +71,10 @@ internal class RoutingSocketGateway(
|
||||
is DomainResult.Success -> delegate(provider.value).setPower(profileId, deviceName, powerState)
|
||||
}
|
||||
|
||||
private fun delegate(type: ProviderType): SocketGateway =
|
||||
if (type == ProviderType.ABOX) real else simulation
|
||||
private fun delegate(type: ProviderType): SocketGateway = when (type) {
|
||||
ProviderType.ABOX -> real
|
||||
ProviderType.LOCAL_EXPERIENCE -> simulation
|
||||
}
|
||||
}
|
||||
|
||||
/** Routes temperature/humidity operations by active provider, mirroring [RoutingSocketGateway]. */
|
||||
@@ -91,8 +93,10 @@ internal class RoutingTemperatureHumidityGateway(
|
||||
is DomainResult.Success -> delegate(provider.value).getReading(profileId, deviceName)
|
||||
}
|
||||
|
||||
private fun delegate(type: ProviderType): TemperatureHumidityGateway =
|
||||
if (type == ProviderType.ABOX) real else simulation
|
||||
private fun delegate(type: ProviderType): TemperatureHumidityGateway = when (type) {
|
||||
ProviderType.ABOX -> real
|
||||
ProviderType.LOCAL_EXPERIENCE -> simulation
|
||||
}
|
||||
}
|
||||
|
||||
/** Routes infrared operations by active provider, mirroring [RoutingSocketGateway]. */
|
||||
@@ -129,6 +133,8 @@ internal class RoutingInfraredGateway(
|
||||
is DomainResult.Success -> delegate(provider.value).downloadCodes(profileId, codes)
|
||||
}
|
||||
|
||||
private fun delegate(type: ProviderType): InfraredGateway =
|
||||
if (type == ProviderType.ABOX) real else simulation
|
||||
private fun delegate(type: ProviderType): InfraredGateway = when (type) {
|
||||
ProviderType.ABOX -> real
|
||||
ProviderType.LOCAL_EXPERIENCE -> simulation
|
||||
}
|
||||
}
|
||||
|
||||
+2
@@ -7,6 +7,7 @@ import com.flagship.abox.manager.testing.fakes.FakeCredentialStore
|
||||
import com.flagship.abox.manager.testing.fakes.FakeLocalSessionGateway
|
||||
import com.flagship.abox.manager.testing.fakes.FakeProviderProfileStore
|
||||
import com.flagship.abox.manager.testing.fakes.FakeSessionGateway
|
||||
import kotlinx.coroutines.ExperimentalCoroutinesApi
|
||||
import kotlinx.coroutines.flow.first
|
||||
import kotlinx.coroutines.test.advanceUntilIdle
|
||||
import kotlinx.coroutines.test.runTest
|
||||
@@ -14,6 +15,7 @@ import org.junit.Assert.assertEquals
|
||||
import org.junit.Rule
|
||||
import org.junit.Test
|
||||
|
||||
@OptIn(ExperimentalCoroutinesApi::class)
|
||||
class ProviderSelectionViewModelTest {
|
||||
@get:Rule
|
||||
val mainDispatcherRule = MainDispatcherRule()
|
||||
|
||||
Reference in New Issue
Block a user