Skip to content

Commit

Permalink
Merge branch 'development'
Browse files Browse the repository at this point in the history
  • Loading branch information
yigitozgumus committed Jul 3, 2024
2 parents 77d2172 + ae7c4ca commit 4054456
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 2 deletions.
2 changes: 1 addition & 1 deletion transmission-test/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ publishing {
create<MavenPublication>("release") {
groupId = "com.trendyol"
artifactId = "transmission-test"
version = "1.0.0"
version = "1.0.4"
afterEvaluate {
from(components["java"])
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package com.yigitozgumus.transmissiontesting

import com.trendyol.transmission.Transmission

inline fun<reified T: Transmission.Data?> List<Transmission.Data>.lastInstanceOf(): T? {
return this.filterIsInstance<T>().last()
}

inline fun<reified T: Transmission.Effect?> List<Transmission.Effect>.lastInstanceOf(): T? {
return this.filterIsInstance<T>().last()
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import kotlinx.coroutines.test.runTest

@OptIn(ExperimentalCoroutinesApi::class)
fun Transformer.testWithEffect(
orderedInitialProcessing: List<Transmission> = emptyList<Transmission>(),
effect: Transmission.Effect,
registry: RegistryScope.() -> Unit = {},
scope: suspend TransformerTestScope.(scope: TestScope) -> Unit
Expand All @@ -33,6 +34,14 @@ fun Transformer.testWithEffect(
override val dataStream: List<Transmission.Data> = dataStream
override val effectStream: List<EffectWrapper> = effectStream
}
orderedInitialProcessing.forEach {
when (it) {
is Transmission.Data -> throw IllegalArgumentException("Transmission.Data should not be sent for processing")
is Transmission.Effect -> testRouter.sendEffect(it)
is Transmission.Signal -> testRouter.sendSignal(it)
}
this@testWithEffect.waitProcessingToFinish()
}
testRouter.sendEffect(effect)
this@testWithEffect.waitProcessingToFinish()
testScope.scope(this)
Expand All @@ -45,6 +54,7 @@ fun Transformer.testWithEffect(

@OptIn(ExperimentalCoroutinesApi::class)
fun Transformer.testWithSignal(
orderedInitialProcessing: List<Transmission> = emptyList<Transmission>(),
signal: Transmission.Signal,
registry: RegistryScope.() -> Unit = {},
scope: suspend TransformerTestScope.(scope: TestScope) -> Unit
Expand All @@ -65,6 +75,14 @@ fun Transformer.testWithSignal(
override val dataStream: List<Transmission.Data> = dataStream
override val effectStream: List<EffectWrapper> = effectStream
}
orderedInitialProcessing.forEach {
when (it) {
is Transmission.Data -> throw IllegalArgumentException("Transmission.Data should not be sent for processing")
is Transmission.Effect -> testRouter.sendEffect(it)
is Transmission.Signal -> testRouter.sendSignal(it)
}
this@testWithSignal.waitProcessingToFinish()
}
testRouter.sendSignal(signal)
this@testWithSignal.waitProcessingToFinish()
testScope.scope(this)
Expand Down
2 changes: 1 addition & 1 deletion transmission/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ publishing {
create<MavenPublication>("release") {
groupId = "com.trendyol"
artifactId = "transmission"
version = "1.0.0"
version = "1.0.4"
afterEvaluate {
from(components["java"])
}
Expand Down

0 comments on commit 4054456

Please sign in to comment.