Skip to content

Commit

Permalink
Fixed failing test
Browse files Browse the repository at this point in the history
  • Loading branch information
rcardin committed Feb 22, 2024
1 parent 8f54925 commit bd595d6
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
5 changes: 3 additions & 2 deletions app/src/main/kotlin/in/rcard/fes/projection/listeners.kt
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import kotlinx.coroutines.channels.awaitClose
import kotlinx.coroutines.channels.trySendBlocking
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.callbackFlow
import kotlinx.coroutines.future.await
import kotlinx.serialization.json.Json
import org.slf4j.Logger

Expand Down Expand Up @@ -49,6 +50,6 @@ fun portfolioCreatedEventFlow(eventStoreClient: EventStoreDBClient): Flow<Portfo
.withEventTypeRegularExpression("portfolio-create")
.build(),
)
eventStoreClient.subscribeToAll(subscriptionListener, subscriptionFilter)
awaitClose()
val subscription = eventStoreClient.subscribeToAll(subscriptionListener, subscriptionFilter).await()
awaitClose { subscription.stop() }
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,10 @@ import `in`.rcard.fes.portfolio.PortfolioId
import `in`.rcard.fes.portfolio.UserId
import `in`.rcard.fes.portfolio.eventType
import `in`.rcard.fes.withEventStoreDb
import io.kotest.core.annotation.Ignored
import io.kotest.core.spec.style.ShouldSpec
import io.kotest.matchers.shouldBe
import kotlinx.coroutines.flow.single
import kotlinx.coroutines.flow.take
import kotlinx.coroutines.future.await
import kotlinx.serialization.encodeToString
import kotlinx.serialization.json.Json
Expand All @@ -21,7 +22,6 @@ import java.util.UUID

private val NOW_MILLIS = Instant.now().toEpochMilli()

@Ignored("This test is ignored because there listener stay up and running")
class PortfolioCreatedEventListenerTest : ShouldSpec({

val logger = LoggerFactory.getLogger(PortfolioCreatedEventListenerTest::class.java)
Expand Down Expand Up @@ -54,9 +54,8 @@ class PortfolioCreatedEventListenerTest : ShouldSpec({
portfolioCreatedEventData,
).await()
val portfolioCreatedEventFlow = portfolioCreatedEventFlow(eventStoreDBClient)
portfolioCreatedEventFlow.collect { actualEvent ->
actualEvent shouldBe portfolioCreatedEvent
}
val actualEvent = portfolioCreatedEventFlow.take(1).single()
actualEvent shouldBe portfolioCreatedEvent
}
}
}
Expand Down

0 comments on commit bd595d6

Please sign in to comment.