refactor: remove compatible provider type
This commit is contained in:
+32
@@ -0,0 +1,32 @@
|
|||||||
|
package com.flagship.abox.manager.session
|
||||||
|
|
||||||
|
import androidx.datastore.preferences.core.PreferenceDataStoreFactory
|
||||||
|
import androidx.datastore.preferences.core.edit
|
||||||
|
import androidx.datastore.preferences.core.stringPreferencesKey
|
||||||
|
import androidx.datastore.preferences.core.stringSetPreferencesKey
|
||||||
|
import com.flagship.abox.manager.session.profile.ProviderProfileStoreImpl
|
||||||
|
import java.io.File
|
||||||
|
import kotlinx.coroutines.flow.first
|
||||||
|
import kotlinx.coroutines.test.runTest
|
||||||
|
import org.junit.Assert.assertNull
|
||||||
|
import org.junit.Assert.assertTrue
|
||||||
|
import org.junit.Test
|
||||||
|
|
||||||
|
class RemovedProviderProfileTest {
|
||||||
|
@Test
|
||||||
|
fun removedCompatibleProfileIsIgnoredAndCannotRemainActive() = runTest {
|
||||||
|
val file = File.createTempFile("removed-provider", ".preferences_pb").apply { delete() }
|
||||||
|
val dataStore = PreferenceDataStoreFactory.create(scope = backgroundScope) { file }
|
||||||
|
dataStore.edit { values ->
|
||||||
|
values[stringSetPreferencesKey("profile_ids")] = setOf("compatible-default")
|
||||||
|
values[stringPreferencesKey("profile_compatible-default_type")] = "COMPATIBLE_BACKEND"
|
||||||
|
values[stringPreferencesKey("profile_compatible-default_name")] = "Compatible backend"
|
||||||
|
values[stringPreferencesKey("active_profile_id")] = "compatible-default"
|
||||||
|
}
|
||||||
|
val store = ProviderProfileStoreImpl(dataStore)
|
||||||
|
|
||||||
|
assertTrue(store.profiles().isEmpty())
|
||||||
|
assertNull(store.activeProfile())
|
||||||
|
assertNull(store.observeActiveProfile().first())
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -25,7 +25,6 @@ value class Password(val value: String) {
|
|||||||
|
|
||||||
enum class ProviderType {
|
enum class ProviderType {
|
||||||
ABOX,
|
ABOX,
|
||||||
COMPATIBLE_BACKEND,
|
|
||||||
LOCAL_EXPERIENCE,
|
LOCAL_EXPERIENCE,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user