From f599d57068925f185d6dd02557b6864c761489b5 Mon Sep 17 00:00:00 2001 From: Nek-12 Date: Mon, 23 Dec 2024 18:47:16 +0100 Subject: [PATCH 1/7] fix: fix plugin live templates --- .idea/AndroidProjectSystem.xml | 6 ++++ .../flowmvi/test/store/NestedRecoverTest.kt | 36 +++++++++++++++++++ .../flowmvi/test/store/StoreExceptionsTest.kt | 5 +++ .../src/main/resources/LiveTemplates.xml | 33 +++++++++++------ 4 files changed, 70 insertions(+), 10 deletions(-) create mode 100644 .idea/AndroidProjectSystem.xml create mode 100644 core/src/jvmTest/kotlin/pro/respawn/flowmvi/test/store/NestedRecoverTest.kt diff --git a/.idea/AndroidProjectSystem.xml b/.idea/AndroidProjectSystem.xml new file mode 100644 index 00000000..4a53bee8 --- /dev/null +++ b/.idea/AndroidProjectSystem.xml @@ -0,0 +1,6 @@ + + + + + \ No newline at end of file diff --git a/core/src/jvmTest/kotlin/pro/respawn/flowmvi/test/store/NestedRecoverTest.kt b/core/src/jvmTest/kotlin/pro/respawn/flowmvi/test/store/NestedRecoverTest.kt new file mode 100644 index 00000000..d483696e --- /dev/null +++ b/core/src/jvmTest/kotlin/pro/respawn/flowmvi/test/store/NestedRecoverTest.kt @@ -0,0 +1,36 @@ +package pro.respawn.flowmvi.test.store + +import io.kotest.assertions.throwables.shouldNotThrowAny +import io.kotest.core.spec.style.FreeSpec +import pro.respawn.flowmvi.logging.log +import pro.respawn.flowmvi.plugins.init +import pro.respawn.flowmvi.plugins.recover +import pro.respawn.flowmvi.test.subscribeAndTest +import pro.respawn.flowmvi.util.asUnconfined +import pro.respawn.flowmvi.util.idle +import pro.respawn.flowmvi.util.testStore + +class NestedRecoverTest : FreeSpec({ + asUnconfined() + "Given a store that throws during state update in init" - { + val store = testStore { + init { + updateState { + throw IllegalArgumentException() + } + } + recover { + log { "Caught exception $it" } + null + } + } + + "then the store must not throw" { + shouldNotThrowAny { + store.subscribeAndTest { + idle() + } + } + } + } +}) diff --git a/core/src/jvmTest/kotlin/pro/respawn/flowmvi/test/store/StoreExceptionsTest.kt b/core/src/jvmTest/kotlin/pro/respawn/flowmvi/test/store/StoreExceptionsTest.kt index 2791fdcb..5fbc1e05 100644 --- a/core/src/jvmTest/kotlin/pro/respawn/flowmvi/test/store/StoreExceptionsTest.kt +++ b/core/src/jvmTest/kotlin/pro/respawn/flowmvi/test/store/StoreExceptionsTest.kt @@ -5,6 +5,7 @@ import io.kotest.core.spec.style.FreeSpec import io.kotest.matchers.collections.shouldBeSingleton import io.kotest.matchers.collections.shouldContain import io.kotest.matchers.collections.shouldContainExactly +import io.kotest.matchers.nulls.shouldBeNull import io.kotest.matchers.nulls.shouldNotBeNull import io.kotest.matchers.shouldBe import kotlinx.coroutines.CancellationException @@ -46,6 +47,7 @@ class StoreExceptionsTest : FreeSpec({ idle() plugin.starts shouldBe 1 plugin.exceptions.shouldContainExactly(e) + isActive shouldBe true } } @@ -118,6 +120,9 @@ class StoreExceptionsTest : FreeSpec({ } "and store that handles exceptions" - { val store = testStore(plugin) { + init { + currentCoroutineContext()[RecoverModule].shouldBeNull() + } recover { currentCoroutineContext()[RecoverModule].shouldNotBeNull() null diff --git a/debugger/ideplugin/src/main/resources/LiveTemplates.xml b/debugger/ideplugin/src/main/resources/LiveTemplates.xml index 34e469c5..f55c3110 100644 --- a/debugger/ideplugin/src/main/resources/LiveTemplates.xml +++ b/debugger/ideplugin/src/main/resources/LiveTemplates.xml @@ -2,31 +2,44 @@ -