-
-
Notifications
You must be signed in to change notification settings - Fork 28
Open
Description
Should the library provide artifacts for easier testing in unit tests? Something like an in-memory store would similar to JdbcSqliteDriver(JdbcSqliteDriver.IN_MEMORY) could be provided. It could have simple implementation like this:
class KStoreInMemoryCodec<T : @Serializable Any>(
private val json: Json,
private val serializer: KSerializer<T>
) : Codec<T> {
private var storedData: String? = null
override suspend fun decode(): T? =
storedData?.let {
try {
json.decodeFromString(serializer, it)
} catch (e: SerializationException) {
null
}
}
override suspend fun encode(value: T?) {
storedData = value?.let { json.encodeToString(serializer, it) }
}
}
xxfast
Metadata
Metadata
Assignees
Labels
No labels