From 13b27957369fb69f92724fd7386f741006520c85 Mon Sep 17 00:00:00 2001 From: Fabrice Lecomte Date: Thu, 10 Apr 2025 23:10:56 +0200 Subject: [PATCH] test: add constant for tags --- src/test/kotlin/eventDemo/Tag.kt | 13 +++++++++++++ .../interfaceLayer/query/GameSimulationTest.kt | 4 ++-- .../business/command/GameCommandHandlerTest.kt | 4 ++-- .../event/projection/GameStateRepositoryTest.kt | 10 +++++++--- .../eventDemo/externalServices/PostgresqlTest.kt | 4 ++-- .../eventDemo/externalServices/RabbitMQTest.kt | 4 ++-- .../kotlin/eventDemo/externalServices/RedisTest.kt | 4 ++-- .../kotlin/eventDemo/libs/event/EventStreamTest.kt | 6 ++++-- .../eventDemo/libs/event/VersionBuilderLocalTest.kt | 3 +++ 9 files changed, 37 insertions(+), 15 deletions(-) create mode 100644 src/test/kotlin/eventDemo/Tag.kt diff --git a/src/test/kotlin/eventDemo/Tag.kt b/src/test/kotlin/eventDemo/Tag.kt new file mode 100644 index 0000000..8824ac4 --- /dev/null +++ b/src/test/kotlin/eventDemo/Tag.kt @@ -0,0 +1,13 @@ +package eventDemo + +import io.kotest.core.Tag + +object Tag { + object Postgresql : Tag() + + object RabbitMQ : Tag() + + object Redis : Tag() + + object Concurrence : Tag() +} diff --git a/src/test/kotlin/eventDemo/adapter/interfaceLayer/query/GameSimulationTest.kt b/src/test/kotlin/eventDemo/adapter/interfaceLayer/query/GameSimulationTest.kt index c279134..f87e60a 100644 --- a/src/test/kotlin/eventDemo/adapter/interfaceLayer/query/GameSimulationTest.kt +++ b/src/test/kotlin/eventDemo/adapter/interfaceLayer/query/GameSimulationTest.kt @@ -1,5 +1,6 @@ package eventDemo.adapter.interfaceLayer.query +import eventDemo.Tag import eventDemo.business.command.GameCommandHandler import eventDemo.business.command.command.GameCommand import eventDemo.business.command.command.IWantToJoinTheGameCommand @@ -24,7 +25,6 @@ import eventDemo.business.notification.WelcomeToTheGameNotification import eventDemo.libs.event.projection.ProjectionSnapshotRepositoryInMemory import eventDemo.testKoinApplicationWithConfig import io.kotest.assertions.nondeterministic.until -import io.kotest.core.NamedTag import io.kotest.core.spec.style.FunSpec import io.kotest.matchers.collections.shouldHaveSize import io.kotest.matchers.equals.shouldBeEqual @@ -44,7 +44,7 @@ import kotlin.time.Duration.Companion.seconds @DelicateCoroutinesApi class GameSimulationTest : FunSpec({ - tags(NamedTag("postgresql")) + tags(Tag.Postgresql) test("Simulation of a game") { withTimeout(2.seconds) { diff --git a/src/test/kotlin/eventDemo/business/command/GameCommandHandlerTest.kt b/src/test/kotlin/eventDemo/business/command/GameCommandHandlerTest.kt index ab75650..4121d6b 100644 --- a/src/test/kotlin/eventDemo/business/command/GameCommandHandlerTest.kt +++ b/src/test/kotlin/eventDemo/business/command/GameCommandHandlerTest.kt @@ -1,5 +1,6 @@ package eventDemo.business.command +import eventDemo.Tag import eventDemo.business.command.command.GameCommand import eventDemo.business.command.command.IWantToJoinTheGameCommand import eventDemo.business.entity.GameId @@ -9,7 +10,6 @@ import eventDemo.business.notification.CommandSuccessNotification import eventDemo.business.notification.Notification import eventDemo.business.notification.WelcomeToTheGameNotification import eventDemo.testKoinApplicationWithConfig -import io.kotest.core.NamedTag import io.kotest.core.spec.style.FunSpec import io.kotest.matchers.collections.shouldContain import io.kotest.matchers.equals.shouldBeEqual @@ -25,7 +25,7 @@ import kotlin.time.Duration.Companion.seconds @OptIn(DelicateCoroutinesApi::class) class GameCommandHandlerTest : FunSpec({ - tags(NamedTag("postgresql")) + tags(Tag.Postgresql) test("handle a command should execute the command") { withTimeout(5.seconds) { diff --git a/src/test/kotlin/eventDemo/business/event/projection/GameStateRepositoryTest.kt b/src/test/kotlin/eventDemo/business/event/projection/GameStateRepositoryTest.kt index cd72c4e..e5ac2ed 100644 --- a/src/test/kotlin/eventDemo/business/event/projection/GameStateRepositoryTest.kt +++ b/src/test/kotlin/eventDemo/business/event/projection/GameStateRepositoryTest.kt @@ -1,5 +1,6 @@ package eventDemo.business.event.projection +import eventDemo.Tag import eventDemo.business.entity.GameId import eventDemo.business.entity.Player import eventDemo.business.event.GameEventHandler @@ -9,7 +10,6 @@ import eventDemo.business.event.projection.gameState.GameStateRepository import eventDemo.testKoinApplicationWithConfig import io.kotest.assertions.nondeterministic.eventually import io.kotest.assertions.nondeterministic.eventuallyConfig -import io.kotest.core.NamedTag import io.kotest.core.spec.style.FunSpec import io.kotest.matchers.collections.shouldHaveSize import io.kotest.matchers.equals.shouldBeEqual @@ -24,7 +24,7 @@ import kotlin.time.Duration.Companion.seconds @OptIn(DelicateCoroutinesApi::class) class GameStateRepositoryTest : FunSpec({ - tags(NamedTag("postgresql")) + tags(Tag.Postgresql) val player1 = Player("Tesla") val player2 = Player(name = "Einstein") @@ -116,6 +116,8 @@ class GameStateRepositoryTest : } test("getUntil should be concurrently secure") { + tags(Tag.Concurrence) + val aggregateId = GameId() testKoinApplicationWithConfig { val repo = get() @@ -155,5 +157,7 @@ class GameStateRepositoryTest : } } - xtest("get should be concurrently secure") { } + xtest("get should be concurrently secure") { + tags(Tag.Concurrence) + } }) diff --git a/src/test/kotlin/eventDemo/externalServices/PostgresqlTest.kt b/src/test/kotlin/eventDemo/externalServices/PostgresqlTest.kt index aac27a5..46c8b3e 100644 --- a/src/test/kotlin/eventDemo/externalServices/PostgresqlTest.kt +++ b/src/test/kotlin/eventDemo/externalServices/PostgresqlTest.kt @@ -1,14 +1,14 @@ package eventDemo.externalServices +import eventDemo.Tag import eventDemo.testKoinApplicationWithConfig -import io.kotest.core.NamedTag import io.kotest.core.spec.style.FunSpec import io.kotest.matchers.equals.shouldBeEqual import javax.sql.DataSource class PostgresqlTest : FunSpec({ - tags(NamedTag("postgresql")) + tags(Tag.Postgresql) test("test connection with postgresql") { testKoinApplicationWithConfig { diff --git a/src/test/kotlin/eventDemo/externalServices/RabbitMQTest.kt b/src/test/kotlin/eventDemo/externalServices/RabbitMQTest.kt index d714ff4..4f21cc7 100644 --- a/src/test/kotlin/eventDemo/externalServices/RabbitMQTest.kt +++ b/src/test/kotlin/eventDemo/externalServices/RabbitMQTest.kt @@ -5,9 +5,9 @@ import com.rabbitmq.client.BuiltinExchangeType import com.rabbitmq.client.ConnectionFactory import com.rabbitmq.client.DefaultConsumer import com.rabbitmq.client.Envelope +import eventDemo.Tag import eventDemo.testKoinApplicationWithConfig import io.kotest.assertions.nondeterministic.eventually -import io.kotest.core.NamedTag import io.kotest.core.spec.style.FunSpec import io.kotest.matchers.string.shouldStartWith import io.mockk.mockk @@ -18,7 +18,7 @@ import kotlin.time.Duration.Companion.seconds class RabbitMQTest : FunSpec({ - tags(NamedTag("rabbitmq")) + tags(Tag.RabbitMQ) test("test connection with RabbitMQ") { testKoinApplicationWithConfig { diff --git a/src/test/kotlin/eventDemo/externalServices/RedisTest.kt b/src/test/kotlin/eventDemo/externalServices/RedisTest.kt index 7d69304..e55299a 100644 --- a/src/test/kotlin/eventDemo/externalServices/RedisTest.kt +++ b/src/test/kotlin/eventDemo/externalServices/RedisTest.kt @@ -1,6 +1,6 @@ package eventDemo.externalServices -import io.kotest.core.NamedTag +import eventDemo.Tag import io.kotest.core.spec.style.FunSpec import io.kotest.matchers.equals.shouldBeEqual import redis.clients.jedis.JedisPooled @@ -9,7 +9,7 @@ private val redisUrl = "redis://localhost:6379" class RedisTest : FunSpec({ - tags(NamedTag("redis")) + tags(Tag.Redis) xtest("test connection with jedis") { JedisPooled(redisUrl).also { diff --git a/src/test/kotlin/eventDemo/libs/event/EventStreamTest.kt b/src/test/kotlin/eventDemo/libs/event/EventStreamTest.kt index c38009b..2d5217d 100644 --- a/src/test/kotlin/eventDemo/libs/event/EventStreamTest.kt +++ b/src/test/kotlin/eventDemo/libs/event/EventStreamTest.kt @@ -1,7 +1,7 @@ package eventDemo.libs.event +import eventDemo.Tag import eventDemo.testKoinApplicationWithConfig -import io.kotest.core.NamedTag import io.kotest.core.spec.style.FunSpec import io.kotest.datatest.withData import io.kotest.matchers.collections.shouldHaveSize @@ -19,7 +19,7 @@ import kotlin.test.assertNotNull @DelicateCoroutinesApi class EventStreamTest : FunSpec({ - tags(NamedTag("postgresql")) + tags(Tag.Postgresql) fun EventStream.with3Events(block: EventStream.(id: IdTest) -> Unit) = also { @@ -103,6 +103,8 @@ class EventStreamTest : } context("publish should be concurrently secure") { + tags(Tag.Concurrence) + testKoinApplicationWithConfig { withData(eventStreams()) { stream -> (0..9) diff --git a/src/test/kotlin/eventDemo/libs/event/VersionBuilderLocalTest.kt b/src/test/kotlin/eventDemo/libs/event/VersionBuilderLocalTest.kt index 927dec1..a5bedb5 100644 --- a/src/test/kotlin/eventDemo/libs/event/VersionBuilderLocalTest.kt +++ b/src/test/kotlin/eventDemo/libs/event/VersionBuilderLocalTest.kt @@ -1,5 +1,6 @@ package eventDemo.libs.event +import eventDemo.Tag import io.kotest.core.spec.style.FunSpec import io.kotest.matchers.equals.shouldBeEqual import kotlinx.coroutines.DelicateCoroutinesApi @@ -22,6 +23,8 @@ class VersionBuilderLocalTest : } test("buildNextVersion concurrently") { + tags(Tag.Concurrence) + val versionBuilder = VersionBuilderLocal() val id = IdTest() (1..20)