All Downloads are FREE. Search and download functionalities are using the official Maven repository.

commonTest.io.github.rotbolt.flakerdata.flakerprefs.PrefsDataStoreTest.kt Maven / Gradle / Ivy

There is a newer version: 0.1.2
Show newest version
package io.github.rotbolt.flakerdata.flakerprefs

import io.github.rotbolt.flakedomain.prefs.FlakerPrefs
import io.github.rotbolt.flakedomain.prefs.RetentionPolicy
import kotlinx.coroutines.flow.first
import kotlinx.coroutines.runBlocking
import kotlin.test.BeforeTest
import kotlin.test.Test
import kotlin.test.assertEquals
import kotlin.test.assertTrue

class PrefsDataStoreTest {

    private lateinit var prefDataStore: PrefDataStore

    @BeforeTest
    fun setup() {
        val dataStore = testDataStore()
        prefDataStore = PrefDataStoreImpl(dataStore)
    }

    @Test
    fun `test save and get prefs`() = runBlocking {
        prefDataStore.savePrefs(
            FlakerPrefs(
                shouldIntercept = true,
                delay = 1000,
                failPercent = 10,
                variancePercent = 10,
                retentionPolicy = RetentionPolicy.ONE_DAY
            )
        )
        val prefs = prefDataStore.getPrefs().first()
        assertTrue(prefs.shouldIntercept)
        assertEquals(1000, prefs.delay)
        assertEquals(10, prefs.failPercent)
        assertEquals(10, prefs.variancePercent)
        assertEquals(prefs.retentionPolicy, RetentionPolicy.ONE_DAY)
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy