Skip to content

Commit f9eee36

Browse files
authored
expose containerFn accross the project #363 (#372)
1 parent e578ce0 commit f9eee36

File tree

21 files changed

+59
-36
lines changed

21 files changed

+59
-36
lines changed

.java-version

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
16.0.2
1+
17.0.10

build.gradle.kts

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import org.jetbrains.kotlin.gradle.dsl.JvmTarget
44
plugins {
55
kotlin("jvm").version(libs.versions.kotlin)
66
alias(libs.plugins.dokka)
7-
alias(libs.plugins.kotlinter)
7+
alias(libs.plugins.spotless)
88
alias(libs.plugins.gitVersioning)
99
`test-report-aggregation`
1010
id("stove-publishing") apply false
@@ -46,7 +46,7 @@ dependencies {
4646
subprojects.of("lib", "spring", "examples", "ktor") {
4747
apply {
4848
plugin("kotlin")
49-
plugin(rootProject.libs.plugins.kotlinter.get().pluginId)
49+
plugin(rootProject.libs.plugins.spotless.get().pluginId)
5050
plugin(rootProject.libs.plugins.dokka.get().pluginId)
5151
plugin("test-report-aggregation")
5252
plugin(rootProject.testLibs.plugins.testLogger.get().pluginId)
@@ -68,9 +68,15 @@ subprojects.of("lib", "spring", "examples", "ktor") {
6868
testImplementation(testLibs.kotest.property.jvm)
6969
}
7070

71+
spotless {
72+
kotlin {
73+
ktlint().setEditorConfigPath(rootProject.layout.projectDirectory.file(".editorconfig"))
74+
}
75+
}
76+
7177
tasks {
7278
test {
73-
dependsOn(formatKotlin)
79+
dependsOn(spotlessApply)
7480
useJUnitPlatform()
7581
testlogger {
7682
setTheme("mocha")
@@ -87,7 +93,7 @@ subprojects.of("lib", "spring", "examples", "ktor") {
8793
}
8894

8995
withType<org.jetbrains.kotlin.gradle.tasks.KotlinCompile> {
90-
dependsOn(formatKotlin, lintKotlin)
96+
dependsOn(spotlessApply)
9197
compilerOptions {
9298
jvmTarget.set(JvmTarget.JVM_17)
9399
allWarningsAsErrors = true

examples/spring-example/src/test/kotlin/com/stove/spring/example/e2e/TestSystemConfig.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@ class TestSystemConfig : AbstractProjectConfig() {
1919
couchbase { CouchbaseSystemOptions("Stove") }
2020
kafka {
2121
KafkaSystemOptions(
22-
containerOptions = KafkaContainerOptions(tag = "latest")
22+
containerOptions = KafkaContainerOptions(tag = "latest") {
23+
}
2324
)
2425
}
2526
bridge()

gradle/libs.versions.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ mongodb = "5.0.0"
3030
wiremock = "3.4.2"
3131
testcontainers = "1.19.7"
3232
r2dbc-mssql = "1.0.2.RELEASE"
33+
spotless = "6.25.0"
3334

3435
[libraries]
3536
kotlin-stdlib-jdk8 = { module = "org.jetbrains.kotlin:kotlin-stdlib-jdk8", version.ref = "kotlin" }
@@ -108,4 +109,5 @@ dokka = { id = "org.jetbrains.dokka", version.ref = "dokka" }
108109
knit = { id = "org.jetbrains.kotlinx:kotlinx-knit", version.ref = "knit" }
109110
kover = { id = "org.jetbrains.kotlinx.kover", version.ref = "kover" }
110111
gitVersioning = { id = "com.palantir.git-version", version = "3.0.0" }
112+
spotless = { id = "com.diffplug.spotless", version.ref = "spotless" }
111113

lib/stove-testing-e2e-couchbase/src/main/kotlin/com/trendyol/stove/testing/e2e/couchbase/Options.kt

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ import com.trendyol.stove.testing.e2e.system.*
1010
import com.trendyol.stove.testing.e2e.system.abstractions.*
1111
import com.trendyol.stove.testing.e2e.system.annotations.StoveDsl
1212
import org.testcontainers.couchbase.*
13-
import org.testcontainers.utility.DockerImageName
1413

1514
data class CouchbaseExposedConfiguration(
1615
val connectionString: String,
@@ -53,8 +52,7 @@ data class CouchbaseContainerOptions(
5352
override val image: String = "couchbase/server",
5453
override val tag: String = "latest",
5554
override val compatibleSubstitute: String? = null,
56-
val containerImageFn: DockerImageName.() -> DockerImageName = { this },
57-
val containerFn: CouchbaseContainer.() -> CouchbaseContainer = { this }
55+
override val containerFn: ContainerFn<CouchbaseContainer> = { }
5856
) : ContainerOptions
5957

6058
internal fun TestSystem.withCouchbase(options: CouchbaseSystemOptions): TestSystem {
@@ -64,10 +62,10 @@ internal fun TestSystem.withCouchbase(options: CouchbaseSystemOptions): TestSyst
6462
registry = options.containerOptions.registry,
6563
compatibleSubstitute = options.containerOptions.compatibleSubstitute
6664
) {
67-
CouchbaseContainer(it.let(options.containerOptions.containerImageFn))
65+
CouchbaseContainer(it)
6866
.withBucket(bucketDefinition)
6967
.withReuse(this.options.keepDependenciesRunning)
70-
.let(options.containerOptions.containerFn)
68+
.apply(options.containerOptions.containerFn)
7169
}
7270
this.getOrRegister(
7371
CouchbaseSystem(this, CouchbaseContext(bucketDefinition, couchbaseContainer, options))

lib/stove-testing-e2e-couchbase/src/test/kotlin/com/trendyol/stove/testing/e2e/couchbase/CouchbaseTestSystemTests.kt

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,9 @@ class Setup : AbstractProjectConfig() {
2727
containerOptions = CouchbaseContainerOptions(
2828
tag = "latest"
2929
)
30-
)
31-
.migrations {
32-
register<DefaultMigration>()
33-
}
30+
).migrations {
31+
register<DefaultMigration>()
32+
}
3433
}
3534
applicationUnderTest(NoOpApplication())
3635
}.run()

lib/stove-testing-e2e-elasticsearch/build.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ plugins {}
22
dependencies {
33
api(projects.lib.stoveTestingE2e)
44
api(libs.elastic)
5-
implementation(libs.testcontainers.elasticsearch)
5+
api(libs.testcontainers.elasticsearch)
66
implementation(libs.jackson.databind)
77
implementation(libs.jackson.arrow)
88
}

lib/stove-testing-e2e-elasticsearch/src/main/kotlin/com/trendyol/stove/testing/e2e/elasticsearch/Extensions.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ internal fun TestSystem.withElasticsearch(options: ElasticsearchSystemOptions):
3232
withEnv("xpack.security.enabled", "false")
3333
}
3434
withReuse(this@withElasticsearch.options.keepDependenciesRunning)
35-
options.container.configureContainer(this)
35+
options.container.containerFn(this)
3636
}
3737
.let { getOrRegister(ElasticsearchSystem(this, ElasticsearchContext(options.defaultIndex.index, it, options))) }
3838
.let { this }

lib/stove-testing-e2e-elasticsearch/src/main/kotlin/com/trendyol/stove/testing/e2e/elasticsearch/Options.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ package com.trendyol.stove.testing.e2e.elasticsearch
33
import arrow.core.*
44
import co.elastic.clients.elasticsearch.ElasticsearchClient
55
import com.fasterxml.jackson.databind.ObjectMapper
6-
import com.trendyol.stove.testing.e2e.containers.ContainerOptions
6+
import com.trendyol.stove.testing.e2e.containers.*
77
import com.trendyol.stove.testing.e2e.database.migrations.*
88
import com.trendyol.stove.testing.e2e.serialization.StoveObjectMapper
99
import com.trendyol.stove.testing.e2e.system.abstractions.*
@@ -58,7 +58,7 @@ data class ElasticContainerOptions(
5858
val exposedPorts: List<Int> = listOf(9200),
5959
val password: String = "password",
6060
val disableSecurity: Boolean = true,
61-
val configureContainer: ElasticsearchContainer.() -> Unit = {}
61+
override val containerFn: ContainerFn<ElasticsearchContainer> = {}
6262
) : ContainerOptions
6363

6464
data class ElasticClientConfigurer(

lib/stove-testing-e2e-kafka/build.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
dependencies {
22
api(projects.lib.stoveTestingE2e)
3+
api(libs.testcontainers.kafka)
34
implementation(libs.kafka)
45
implementation(libs.kotlinx.io.reactor.extensions)
56
implementation(libs.kotlinx.jdk8)
67
implementation(libs.kotlinx.core)
78
implementation(libs.kafkaKotlin)
8-
implementation(libs.testcontainers.kafka)
99
}
1010

1111
dependencies {

0 commit comments

Comments
 (0)