From 70db58e5e6a10b88b0d13e15e7e02b4f116c4e51 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ivan=20=E2=80=9CCLOVIS=E2=80=9D=20Canet?= Date: Mon, 10 Aug 2026 22:34:59 +0200 Subject: [PATCH] test(test-legacy): Migrate to the unified API --- driver-coroutines-kmongo/src/jvmMain/kotlin/KMongoExt.kt | 8 ++++---- test-legacy/src/commonMain/kotlin/TestDatabase.kt | 6 +++--- test-legacy/src/commonTest/kotlin/AggregationTests.kt | 5 ++--- .../src/commonTest/kotlin/FilteredCollectionTest.kt | 1 - .../src/commonTest/kotlin/studies/AggregationLookup.kt | 2 +- .../kotlin/studies/AggregationProjectUnionWith.kt | 8 ++++---- test-legacy/src/jvmMain/kotlin/TestDatabase.jvm.kt | 8 ++++---- 7 files changed, 18 insertions(+), 20 deletions(-) diff --git a/driver-coroutines-kmongo/src/jvmMain/kotlin/KMongoExt.kt b/driver-coroutines-kmongo/src/jvmMain/kotlin/KMongoExt.kt index 9c07e73b..1bb057d3 100644 --- a/driver-coroutines-kmongo/src/jvmMain/kotlin/KMongoExt.kt +++ b/driver-coroutines-kmongo/src/jvmMain/kotlin/KMongoExt.kt @@ -17,8 +17,8 @@ package opensavvy.ktmongo.coroutines.kmongo import com.mongodb.reactivestreams.client.MongoCollection -import opensavvy.ktmongo.coroutines.JvmMongoCollection -import opensavvy.ktmongo.coroutines.asKtMongoLegacy +import opensavvy.ktmongo.coroutines.CoroutineMongoCollection +import opensavvy.ktmongo.coroutines.asKtMongo import opensavvy.ktmongo.dsl.path.PropertyNameStrategy import opensavvy.ktmongo.utils.kmongo.KMongoNameStrategy @@ -27,5 +27,5 @@ import opensavvy.ktmongo.utils.kmongo.KMongoNameStrategy */ inline fun MongoCollection.asKtMongo( nameStrategy: PropertyNameStrategy = KMongoNameStrategy(), -): JvmMongoCollection = - com.mongodb.kotlin.client.coroutine.MongoCollection(this).asKtMongoLegacy(nameStrategy) +): CoroutineMongoCollection = + com.mongodb.kotlin.client.coroutine.MongoCollection(this).asKtMongo(propertyNameStrategy = nameStrategy) diff --git a/test-legacy/src/commonMain/kotlin/TestDatabase.kt b/test-legacy/src/commonMain/kotlin/TestDatabase.kt index 2028f6da..8bcf9bc1 100644 --- a/test-legacy/src/commonMain/kotlin/TestDatabase.kt +++ b/test-legacy/src/commonMain/kotlin/TestDatabase.kt @@ -17,17 +17,17 @@ package opensavvy.ktmongo.test import kotlinx.coroutines.ensureActive -import opensavvy.ktmongo.coroutines.MongoCollection +import opensavvy.ktmongo.coroutines.CoroutineMongoCollection import opensavvy.prepared.suite.PreparedProvider import opensavvy.prepared.suite.cleanUp import opensavvy.prepared.suite.prepared import opensavvy.prepared.suite.random.randomInt import kotlin.coroutines.coroutineContext -expect inline fun testCollectionExact(name: String): PreparedProvider> +expect inline fun testCollectionExact(name: String): PreparedProvider> val collectionPostfix by randomInt(0, Int.MAX_VALUE) -inline fun testCollection(name: String): PreparedProvider> = prepared { +inline fun testCollection(name: String): PreparedProvider> = prepared { val name = "$name-${collectionPostfix()}" val realCollection by testCollectionExact(name) diff --git a/test-legacy/src/commonTest/kotlin/AggregationTests.kt b/test-legacy/src/commonTest/kotlin/AggregationTests.kt index ceb347f9..a45bd6d3 100644 --- a/test-legacy/src/commonTest/kotlin/AggregationTests.kt +++ b/test-legacy/src/commonTest/kotlin/AggregationTests.kt @@ -19,9 +19,8 @@ package opensavvy.ktmongo.sync import kotlinx.serialization.Serializable -import opensavvy.ktmongo.coroutines.filter -import opensavvy.ktmongo.coroutines.first -import opensavvy.ktmongo.coroutines.toList +import opensavvy.ktmongo.api.first +import opensavvy.ktmongo.api.toList import opensavvy.ktmongo.dsl.DangerousMongoApi import opensavvy.ktmongo.dsl.LowLevelApi import opensavvy.ktmongo.test.testCollection diff --git a/test-legacy/src/commonTest/kotlin/FilteredCollectionTest.kt b/test-legacy/src/commonTest/kotlin/FilteredCollectionTest.kt index 6a68b016..814ee5f4 100644 --- a/test-legacy/src/commonTest/kotlin/FilteredCollectionTest.kt +++ b/test-legacy/src/commonTest/kotlin/FilteredCollectionTest.kt @@ -17,7 +17,6 @@ package opensavvy.ktmongo.sync import kotlinx.serialization.Serializable -import opensavvy.ktmongo.coroutines.filter import opensavvy.ktmongo.test.testCollection import opensavvy.prepared.runner.testballoon.preparedSuite import opensavvy.prepared.suite.config.CoroutineTimeout diff --git a/test-legacy/src/commonTest/kotlin/studies/AggregationLookup.kt b/test-legacy/src/commonTest/kotlin/studies/AggregationLookup.kt index 3b8fa30a..f92e9923 100644 --- a/test-legacy/src/commonTest/kotlin/studies/AggregationLookup.kt +++ b/test-legacy/src/commonTest/kotlin/studies/AggregationLookup.kt @@ -19,8 +19,8 @@ package opensavvy.ktmongo.sync.studies import kotlinx.serialization.Serializable +import opensavvy.ktmongo.api.toList import opensavvy.ktmongo.bson.types.ObjectId -import opensavvy.ktmongo.coroutines.toList import opensavvy.ktmongo.test.testCollection import opensavvy.prepared.runner.testballoon.preparedSuite import kotlin.time.Instant diff --git a/test-legacy/src/commonTest/kotlin/studies/AggregationProjectUnionWith.kt b/test-legacy/src/commonTest/kotlin/studies/AggregationProjectUnionWith.kt index 0706820c..cc6f05e5 100644 --- a/test-legacy/src/commonTest/kotlin/studies/AggregationProjectUnionWith.kt +++ b/test-legacy/src/commonTest/kotlin/studies/AggregationProjectUnionWith.kt @@ -17,8 +17,8 @@ package opensavvy.ktmongo.sync.studies import kotlinx.serialization.Serializable -import opensavvy.ktmongo.coroutines.MongoAggregationPipeline -import opensavvy.ktmongo.coroutines.toList +import opensavvy.ktmongo.api.toList +import opensavvy.ktmongo.coroutines.CoroutineMongoAggregationPipeline import opensavvy.ktmongo.dsl.aggregation.stages.ProjectStageOperators import opensavvy.ktmongo.dsl.query.FilterQuery import opensavvy.ktmongo.test.testCollection @@ -201,7 +201,7 @@ val AggregationProjectUnionWith by preparedSuite { * const commonSort = {$sort: {'customer.name': -1}}; * ``` */ - fun MongoAggregationPipeline.commonSort() = sort { + fun CoroutineMongoAggregationPipeline.commonSort() = sort { descending(Invoice::customer / Customer::name) } @@ -212,7 +212,7 @@ val AggregationProjectUnionWith by preparedSuite { * const commonLimit = {$limit: 20}; * ``` */ - fun MongoAggregationPipeline.commonLimit() = limit(20) + fun CoroutineMongoAggregationPipeline.commonLimit() = limit(20) test("Case study with \$unionWith") { drafts().insertOne( diff --git a/test-legacy/src/jvmMain/kotlin/TestDatabase.jvm.kt b/test-legacy/src/jvmMain/kotlin/TestDatabase.jvm.kt index 690e9a6e..55d909b5 100644 --- a/test-legacy/src/jvmMain/kotlin/TestDatabase.jvm.kt +++ b/test-legacy/src/jvmMain/kotlin/TestDatabase.jvm.kt @@ -19,8 +19,8 @@ package opensavvy.ktmongo.test import com.mongodb.MongoTimeoutException import com.mongodb.kotlin.client.coroutine.MongoClient import kotlinx.coroutines.CoroutineName -import opensavvy.ktmongo.coroutines.MongoCollection -import opensavvy.ktmongo.coroutines.asKtMongoLegacy +import opensavvy.ktmongo.coroutines.CoroutineMongoCollection +import opensavvy.ktmongo.coroutines.asKtMongo import opensavvy.prepared.suite.PreparedProvider import opensavvy.prepared.suite.prepared import opensavvy.prepared.suite.shared @@ -38,7 +38,7 @@ internal val database by shared(CoroutineName("mongodb-establish-connection")) { client.getDatabase("ktmongo-sync-tests") } -actual inline fun testCollectionExact(name: String): PreparedProvider> = prepared(CoroutineName("mongodb-create-collection-$name")) { +actual inline fun testCollectionExact(name: String): PreparedProvider> = prepared(CoroutineName("mongodb-create-collection-$name")) { val collection = database().getCollection(name) - collection.asKtMongoLegacy() + collection.asKtMongo() } -- 2.51.2