From f7ff1f645b52a63ad6204c628e4d177fd9e62ab4 Mon Sep 17 00:00:00 2001 From: BoD Date: Tue, 8 Apr 2025 10:09:12 +0200 Subject: [PATCH] Don't depend on apollo-testing-support-internal (cherry picked from commit 1b44de3d6f59dec26e077bb30734a1f8773cac37) --- gradle/libs.versions.toml | 3 ++ normalized-cache-incubating/build.gradle.kts | 2 +- .../cache/normalized/internal/LruCacheTest.kt | 2 +- .../build.gradle.kts | 1 - test-utils/api/test-utils.api | 45 +++++++++++++++++++ test-utils/api/test-utils.klib.api | 38 ++++++++++++++++ test-utils/build.gradle.kts | 6 +++ .../testing/currentThreadId.apple.kt | 9 ++++ .../normalized/testing/platform.apple.kt | 9 ++++ .../normalized/testing/readFile.apple.kt | 5 +++ .../normalized/testing/FilesystemCommon.kt | 32 +++++++++++++ .../cache/normalized/testing/channels.kt | 20 +++++++++ .../normalized/testing/currentThreadId.kt | 3 ++ .../cache/normalized/testing/platform.kt | 12 +++++ .../cache/normalized/testing/readFile.kt | 17 +++++++ .../cache/normalized/testing/runTest.kt | 24 ++++++++++ .../normalized/testing/readFile.concurrent.kt | 10 +++++ .../testing/currentThreadId.jsCommon.kt | 5 +++ .../cache/normalized/testing/platform.js.kt | 10 +++++ .../cache/normalized/testing/readFile.js.kt | 11 +++++ .../testing/currentThreadId.jvmCommon.kt | 6 +++ .../normalized/testing/platform.jvmCommon.kt | 9 ++++ .../cache/normalized/testing/readFile.jvm.kt | 14 ++++++ .../normalized/testing/platform.wasmJs.kt | 9 ++++ .../normalized/testing/readFile.wasmJs.kt | 20 +++++++++ tests/cache-control/build.gradle.kts | 3 +- .../ClientAndServerSideCacheControlTest.kt | 2 +- .../kotlin/ClientSideCacheControlTest.kt | 2 +- .../src/commonTest/kotlin/DoNotStoreTest.kt | 2 +- .../kotlin/ServerSideCacheControlTest.kt | 2 +- .../build.gradle.kts | 2 +- .../src/commonTest/kotlin/test/IncludeTest.kt | 2 +- tests/defer/build.gradle.kts | 3 +- .../kotlin/test/DeferNormalizedCacheTest.kt | 6 ++- tests/garbage-collection/build.gradle.kts | 3 +- .../kotlin/DanglingReferencesTest.kt | 2 +- .../commonTest/kotlin/GarbageCollectTest.kt | 2 +- .../kotlin/ReachableCacheKeysTest.kt | 2 +- .../src/commonTest/kotlin/StaleFieldsTest.kt | 2 +- .../build.gradle.kts | 2 +- .../src/commonTest/kotlin/IncludeTest.kt | 2 +- tests/migration/build.gradle.kts | 2 +- .../src/commonTest/kotlin/MigrationTest.kt | 2 +- .../build.gradle.kts | 2 +- .../src/commonTest/kotlin/Utils.kt | 2 +- .../src/commonTest/kotlin/test/BasicTest.kt | 2 +- .../src/commonTest/kotlin/test/StoreTest.kt | 2 +- tests/models-operation-based/build.gradle.kts | 2 +- .../src/commonTest/kotlin/Utils.kt | 2 +- .../src/commonTest/kotlin/test/BasicTest.kt | 2 +- .../src/commonTest/kotlin/test/StoreTest.kt | 2 +- tests/models-response-based/build.gradle.kts | 2 +- .../src/commonTest/kotlin/Utils.kt | 2 +- .../src/commonTest/kotlin/test/BasicTest.kt | 2 +- .../src/commonTest/kotlin/test/StoreTest.kt | 2 +- tests/normalization-tests/build.gradle.kts | 2 +- .../kotlin/com/example/NormalizationTest.kt | 2 +- tests/normalized-cache/build.gradle.kts | 2 +- .../src/commonTest/kotlin/BasicTest.kt | 2 +- .../src/commonTest/kotlin/CacheFlagsTest.kt | 2 +- .../commonTest/kotlin/CacheResolverTest.kt | 2 +- .../src/commonTest/kotlin/CancelTest.kt | 2 +- .../src/commonTest/kotlin/ExceptionsTest.kt | 2 +- .../src/commonTest/kotlin/FetchPolicyTest.kt | 5 +-- .../kotlin/IdCacheKeyGeneratorTest.kt | 2 +- .../src/commonTest/kotlin/JsonScalarTest.kt | 2 +- .../src/commonTest/kotlin/MemoryCacheTest.kt | 2 +- .../commonTest/kotlin/NormalizationTest.kt | 2 +- .../kotlin/NormalizedCacheThreadingTest.kt | 2 +- .../commonTest/kotlin/OptimisticCacheTest.kt | 3 +- .../src/commonTest/kotlin/OtherCacheTest.kt | 2 +- .../src/commonTest/kotlin/StoreTest.kt | 2 +- .../src/commonTest/kotlin/ThreadTests.kt | 6 +-- .../src/commonTest/kotlin/Utils.kt | 4 +- .../kotlin/WatcherErrorHandlingTest.kt | 3 +- .../src/commonTest/kotlin/WatcherTest.kt | 2 +- .../kotlin/circular/CircularCacheReadTest.kt | 5 +-- .../declarativecache/DeclarativeCacheTest.kt | 15 +++---- .../FragmentNormalizerTest.kt | 5 +-- .../kotlin/MemoryCacheOnlyTest.kt | 2 +- .../src/jvmTest/kotlin/ApqCacheTest.kt | 2 +- .../jvmTest/kotlin/CacheConcurrencyTest.kt | 2 +- .../kotlin/CacheMissLoggingInterceptorTest.kt | 2 +- .../kotlin/WriteToCacheAsynchronouslyTest.kt | 2 +- tests/number-scalar/build.gradle.kts | 1 + .../src/commonTest/kotlin/test/NumberTest.kt | 2 +- tests/optimistic-data/build.gradle.kts | 2 +- .../jvmTest/kotlin/test/OptimisticDataTest.kt | 2 +- tests/pagination/build.gradle.kts | 1 + .../kotlin/ConnectionPaginationTest.kt | 2 +- .../ConnectionProgrammaticPaginationTest.kt | 2 +- .../ConnectionWithNodesPaginationTest.kt | 2 +- .../kotlin/CursorBasedPaginationTest.kt | 2 +- .../src/commonTest/kotlin/EmbedTest.kt | 2 +- .../OffsetBasedWithArrayPaginationTest.kt | 2 +- ...fsetBasedWithPageAndInputPaginationTest.kt | 2 +- .../OffsetBasedWithPagePaginationTest.kt | 2 +- tests/partial-results/build.gradle.kts | 3 +- .../kotlin/test/CachePartialResultTest.kt | 2 +- tests/schema-changes/build.gradle.kts | 2 +- .../commonTest/kotlin/test/SchemaChanges.kt | 2 +- tests/store-errors/build.gradle.kts | 3 +- .../commonTest/kotlin/test/StoreErrorsTest.kt | 2 +- 103 files changed, 411 insertions(+), 104 deletions(-) create mode 100644 test-utils/src/appleMain/kotlin/com/apollographql/cache/normalized/testing/currentThreadId.apple.kt create mode 100644 test-utils/src/appleMain/kotlin/com/apollographql/cache/normalized/testing/platform.apple.kt create mode 100644 test-utils/src/appleMain/kotlin/com/apollographql/cache/normalized/testing/readFile.apple.kt create mode 100644 test-utils/src/commonMain/kotlin/com/apollographql/cache/normalized/testing/FilesystemCommon.kt create mode 100644 test-utils/src/commonMain/kotlin/com/apollographql/cache/normalized/testing/channels.kt create mode 100644 test-utils/src/commonMain/kotlin/com/apollographql/cache/normalized/testing/currentThreadId.kt create mode 100644 test-utils/src/commonMain/kotlin/com/apollographql/cache/normalized/testing/platform.kt create mode 100644 test-utils/src/commonMain/kotlin/com/apollographql/cache/normalized/testing/readFile.kt create mode 100644 test-utils/src/commonMain/kotlin/com/apollographql/cache/normalized/testing/runTest.kt create mode 100644 test-utils/src/concurrentMain/kotlin/com/apollographql/cache/normalized/testing/readFile.concurrent.kt create mode 100644 test-utils/src/jsCommonMain/kotlin/com/apollographql/cache/normalized/testing/currentThreadId.jsCommon.kt create mode 100644 test-utils/src/jsMain/kotlin/com/apollographql/cache/normalized/testing/platform.js.kt create mode 100644 test-utils/src/jsMain/kotlin/com/apollographql/cache/normalized/testing/readFile.js.kt create mode 100644 test-utils/src/jvmCommonMain/kotlin/com/apollographql/cache/normalized/testing/currentThreadId.jvmCommon.kt create mode 100644 test-utils/src/jvmCommonMain/kotlin/com/apollographql/cache/normalized/testing/platform.jvmCommon.kt create mode 100644 test-utils/src/jvmMain/kotlin/com/apollographql/cache/normalized/testing/readFile.jvm.kt create mode 100644 test-utils/src/wasmJsMain/kotlin/com/apollographql/cache/normalized/testing/platform.wasmJs.kt create mode 100644 test-utils/src/wasmJsMain/kotlin/com/apollographql/cache/normalized/testing/readFile.wasmJs.kt diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index c63c76df..8305a1e3 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -7,6 +7,7 @@ atomicfu = "0.23.1" # Must be the same version as the one used by apollo-testing sqldelight = "2.0.1" androidx-sqlite = "2.3.1" librarian = "0.0.8-SNAPSHOT-cd822254de75426f8f047a50bae467da872cc912" +kotlinx-coroutines = "1.9.0" [libraries] apollo-api = { group = "com.apollographql.apollo", name = "apollo-api", version.ref = "apollo" } @@ -24,6 +25,7 @@ atomicfu-plugin = { group = "org.jetbrains.kotlinx", name = "atomicfu-gradle-plu kotlin-test = { group = "org.jetbrains.kotlin", name = "kotlin-test" } # the Kotlin plugin resolves the version kotlin-test-junit = { group = "org.jetbrains.kotlin", name = "kotlin-test-junit" } # the Kotlin plugin resolves the version okio = { group = "com.squareup.okio", name = "okio", version.ref = "okio" } +okio-nodefilesystem = { group = "com.squareup.okio", name = "okio-nodefilesystem", version.ref = "okio" } uuid = "com.benasher44:uuid:0.8.2" sqldelight-android = { group = "app.cash.sqldelight", name = "android-driver", version.ref = "sqldelight" } sqldelight-jvm = { group = "app.cash.sqldelight", name = "sqlite-driver", version.ref = "sqldelight" } @@ -37,6 +39,7 @@ androidx-sqlite-framework = { group = "androidx.sqlite", name = "sqlite-framewor androidx-startup-runtime = "androidx.startup:startup-runtime:1.1.1" kotlin-poet = { group = "com.squareup", name = "kotlinpoet", version = "1.18.1" } kotlin-plugin = { group = "org.jetbrains.kotlin", name = "kotlin-gradle-plugin", version.ref = "kotlin-plugin" } +kotlinx-coroutines-test = { group = "org.jetbrains.kotlinx", name = "kotlinx-coroutines-test", version.ref = "kotlinx-coroutines" } librarian = { module = "com.gradleup.librarian:librarian-gradle-plugin", version.ref = "librarian"} android-plugin = { module = "com.android.tools.build:gradle", version.ref = "android-plugin"} sqldelight-plugin = { module = "app.cash.sqldelight:gradle-plugin", version.ref = "sqldelight"} diff --git a/normalized-cache-incubating/build.gradle.kts b/normalized-cache-incubating/build.gradle.kts index 8327047c..5a27cde7 100644 --- a/normalized-cache-incubating/build.gradle.kts +++ b/normalized-cache-incubating/build.gradle.kts @@ -28,7 +28,7 @@ kotlin { getByName("commonTest") { dependencies { implementation(libs.kotlin.test) - implementation(libs.apollo.testing.support) + implementation(project(":test-utils")) } } } diff --git a/normalized-cache-incubating/src/commonTest/kotlin/com/apollographql/cache/normalized/internal/LruCacheTest.kt b/normalized-cache-incubating/src/commonTest/kotlin/com/apollographql/cache/normalized/internal/LruCacheTest.kt index d2655e05..51db4947 100644 --- a/normalized-cache-incubating/src/commonTest/kotlin/com/apollographql/cache/normalized/internal/LruCacheTest.kt +++ b/normalized-cache-incubating/src/commonTest/kotlin/com/apollographql/cache/normalized/internal/LruCacheTest.kt @@ -1,7 +1,7 @@ package com.apollographql.cache.normalized.internal -import com.apollographql.apollo.testing.internal.runTest import com.apollographql.cache.normalized.memory.internal.LruCache +import com.apollographql.cache.normalized.testing.runTest import kotlinx.coroutines.delay import kotlin.test.Test import kotlin.test.assertEquals diff --git a/normalized-cache-sqlite-incubating/build.gradle.kts b/normalized-cache-sqlite-incubating/build.gradle.kts index 66cfcca4..7dca1d6d 100644 --- a/normalized-cache-sqlite-incubating/build.gradle.kts +++ b/normalized-cache-sqlite-incubating/build.gradle.kts @@ -86,7 +86,6 @@ kotlin { getByName("commonTest") { dependencies { implementation(libs.kotlin.test) - implementation(libs.apollo.testing.support) implementation(project(":test-utils")) } } diff --git a/test-utils/api/test-utils.api b/test-utils/api/test-utils.api index a2db1fd7..4867b3e4 100644 --- a/test-utils/api/test-utils.api +++ b/test-utils/api/test-utils.api @@ -1,11 +1,56 @@ +public final class com/apollographql/cache/normalized/testing/-FileSystemCommon { + public static final fun pathToJsonReader (Ljava/lang/String;)Lcom/apollographql/apollo/api/json/JsonReader; + public static final fun pathToUtf8 (Ljava/lang/String;)Ljava/lang/String; +} + public final class com/apollographql/cache/normalized/testing/CacheKeyKt { public static final fun append-eNSUWrY (Ljava/lang/String;[Ljava/lang/String;)Ljava/lang/String; public static final fun fieldKey-eNSUWrY (Ljava/lang/String;Ljava/lang/String;)Ljava/lang/String; public static final fun keyToString-pWl1Des (Ljava/lang/String;)Ljava/lang/String; } +public final class com/apollographql/cache/normalized/testing/ChannelsKt { + public static final fun assertNoElement (Lkotlinx/coroutines/channels/Channel;JLkotlin/coroutines/Continuation;)Ljava/lang/Object; + public static synthetic fun assertNoElement$default (Lkotlinx/coroutines/channels/Channel;JLkotlin/coroutines/Continuation;ILjava/lang/Object;)Ljava/lang/Object; + public static final fun awaitElement (Lkotlinx/coroutines/channels/Channel;JLkotlin/coroutines/Continuation;)Ljava/lang/Object; + public static synthetic fun awaitElement$default (Lkotlinx/coroutines/channels/Channel;JLkotlin/coroutines/Continuation;ILjava/lang/Object;)Ljava/lang/Object; +} + +public final class com/apollographql/cache/normalized/testing/CurrentThreadId_jvmCommonKt { + public static final fun currentThreadId ()Ljava/lang/String; +} + public final class com/apollographql/cache/normalized/testing/ErrorsKt { public static final fun assertErrorsEquals (Lcom/apollographql/apollo/api/Error;Lcom/apollographql/apollo/api/Error;)V public static final fun assertErrorsEquals (Ljava/lang/Iterable;Ljava/lang/Iterable;)V } +public final class com/apollographql/cache/normalized/testing/Platform : java/lang/Enum { + public static final field Js Lcom/apollographql/cache/normalized/testing/Platform; + public static final field Jvm Lcom/apollographql/cache/normalized/testing/Platform; + public static final field Native Lcom/apollographql/cache/normalized/testing/Platform; + public static final field WasmJs Lcom/apollographql/cache/normalized/testing/Platform; + public static fun getEntries ()Lkotlin/enums/EnumEntries; + public static fun valueOf (Ljava/lang/String;)Lcom/apollographql/cache/normalized/testing/Platform; + public static fun values ()[Lcom/apollographql/cache/normalized/testing/Platform; +} + +public final class com/apollographql/cache/normalized/testing/Platform_jvmCommonKt { + public static final fun platform ()Lcom/apollographql/cache/normalized/testing/Platform; +} + +public final class com/apollographql/cache/normalized/testing/ReadFile_concurrentKt { + public static final fun getHostFileSystem ()Lokio/FileSystem; +} + +public final class com/apollographql/cache/normalized/testing/ReadFile_jvmKt { + public static final fun getTestsPath ()Ljava/lang/String; + public static final fun shouldUpdateTestFixtures ()Z +} + +public final class com/apollographql/cache/normalized/testing/RunTestKt { + public static final fun runTest (Lkotlin/jvm/functions/Function2;)V + public static final fun runTest (Lkotlin/jvm/functions/Function2;Lkotlin/jvm/functions/Function2;Lkotlin/jvm/functions/Function2;)V + public static synthetic fun runTest$default (Lkotlin/jvm/functions/Function2;Lkotlin/jvm/functions/Function2;Lkotlin/jvm/functions/Function2;ILjava/lang/Object;)V +} + diff --git a/test-utils/api/test-utils.klib.api b/test-utils/api/test-utils.klib.api index 285511c4..366049c2 100644 --- a/test-utils/api/test-utils.klib.api +++ b/test-utils/api/test-utils.klib.api @@ -1,13 +1,51 @@ // Klib ABI Dump // Targets: [iosArm64, iosSimulatorArm64, iosX64, js, macosArm64, macosX64, tvosArm64, tvosSimulatorArm64, tvosX64, wasmJs, watchosArm32, watchosArm64, watchosSimulatorArm64] +// Alias: apple => [iosArm64, iosSimulatorArm64, iosX64, macosArm64, macosX64, tvosArm64, tvosSimulatorArm64, tvosX64, watchosArm32, watchosArm64, watchosSimulatorArm64] // Rendering settings: // - Signature version: 2 // - Show manifest properties: true // - Show declarations: true // Library unique name: +final enum class com.apollographql.cache.normalized.testing/Platform : kotlin/Enum { // com.apollographql.cache.normalized.testing/Platform|null[0] + enum entry Js // com.apollographql.cache.normalized.testing/Platform.Js|null[0] + enum entry Jvm // com.apollographql.cache.normalized.testing/Platform.Jvm|null[0] + enum entry Native // com.apollographql.cache.normalized.testing/Platform.Native|null[0] + enum entry WasmJs // com.apollographql.cache.normalized.testing/Platform.WasmJs|null[0] + + final val entries // com.apollographql.cache.normalized.testing/Platform.entries|#static{}entries[0] + final fun (): kotlin.enums/EnumEntries // com.apollographql.cache.normalized.testing/Platform.entries.|#static(){}[0] + + final fun valueOf(kotlin/String): com.apollographql.cache.normalized.testing/Platform // com.apollographql.cache.normalized.testing/Platform.valueOf|valueOf#static(kotlin.String){}[0] + final fun values(): kotlin/Array // com.apollographql.cache.normalized.testing/Platform.values|values#static(){}[0] +} + +final val com.apollographql.cache.normalized.testing/HostFileSystem // com.apollographql.cache.normalized.testing/HostFileSystem|{}HostFileSystem[0] + final fun (): okio/FileSystem // com.apollographql.cache.normalized.testing/HostFileSystem.|(){}[0] +final val com.apollographql.cache.normalized.testing/testsPath // com.apollographql.cache.normalized.testing/testsPath|{}testsPath[0] + final fun (): kotlin/String // com.apollographql.cache.normalized.testing/testsPath.|(){}[0] + final fun (com.apollographql.cache.normalized.api/CacheKey).com.apollographql.cache.normalized.testing/append(kotlin/Array...): com.apollographql.cache.normalized.api/CacheKey // com.apollographql.cache.normalized.testing/append|append@com.apollographql.cache.normalized.api.CacheKey(kotlin.Array...){}[0] final fun (com.apollographql.cache.normalized.api/CacheKey).com.apollographql.cache.normalized.testing/fieldKey(kotlin/String): kotlin/String // com.apollographql.cache.normalized.testing/fieldKey|fieldKey@com.apollographql.cache.normalized.api.CacheKey(kotlin.String){}[0] final fun (com.apollographql.cache.normalized.api/CacheKey).com.apollographql.cache.normalized.testing/keyToString(): kotlin/String // com.apollographql.cache.normalized.testing/keyToString|keyToString@com.apollographql.cache.normalized.api.CacheKey(){}[0] final fun com.apollographql.cache.normalized.testing/assertErrorsEquals(com.apollographql.apollo.api/Error?, com.apollographql.apollo.api/Error?) // com.apollographql.cache.normalized.testing/assertErrorsEquals|assertErrorsEquals(com.apollographql.apollo.api.Error?;com.apollographql.apollo.api.Error?){}[0] final fun com.apollographql.cache.normalized.testing/assertErrorsEquals(kotlin.collections/Iterable?, kotlin.collections/Iterable?) // com.apollographql.cache.normalized.testing/assertErrorsEquals|assertErrorsEquals(kotlin.collections.Iterable?;kotlin.collections.Iterable?){}[0] +final fun com.apollographql.cache.normalized.testing/currentThreadId(): kotlin/String // com.apollographql.cache.normalized.testing/currentThreadId|currentThreadId(){}[0] +final fun com.apollographql.cache.normalized.testing/pathToJsonReader(kotlin/String): com.apollographql.apollo.api.json/JsonReader // com.apollographql.cache.normalized.testing/pathToJsonReader|pathToJsonReader(kotlin.String){}[0] +final fun com.apollographql.cache.normalized.testing/pathToUtf8(kotlin/String): kotlin/String // com.apollographql.cache.normalized.testing/pathToUtf8|pathToUtf8(kotlin.String){}[0] +final fun com.apollographql.cache.normalized.testing/platform(): com.apollographql.cache.normalized.testing/Platform // com.apollographql.cache.normalized.testing/platform|platform(){}[0] +final fun com.apollographql.cache.normalized.testing/shouldUpdateTestFixtures(): kotlin/Boolean // com.apollographql.cache.normalized.testing/shouldUpdateTestFixtures|shouldUpdateTestFixtures(){}[0] +final suspend fun <#A: kotlin/Any?> (kotlinx.coroutines.channels/Channel<#A>).com.apollographql.cache.normalized.testing/assertNoElement(kotlin/Long = ...) // com.apollographql.cache.normalized.testing/assertNoElement|assertNoElement@kotlinx.coroutines.channels.Channel<0:0>(kotlin.Long){0§}[0] +final suspend fun <#A: kotlin/Any?> (kotlinx.coroutines.channels/Channel<#A>).com.apollographql.cache.normalized.testing/awaitElement(kotlin/Long = ...): #A // com.apollographql.cache.normalized.testing/awaitElement|awaitElement@kotlinx.coroutines.channels.Channel<0:0>(kotlin.Long){0§}[0] + +// Targets: [apple] +final fun com.apollographql.cache.normalized.testing/runTest(kotlin.coroutines/SuspendFunction1 = ..., kotlin.coroutines/SuspendFunction1 = ..., kotlin.coroutines/SuspendFunction1) // com.apollographql.cache.normalized.testing/runTest|runTest(kotlin.coroutines.SuspendFunction1;kotlin.coroutines.SuspendFunction1;kotlin.coroutines.SuspendFunction1){}[0] + +// Targets: [apple] +final fun com.apollographql.cache.normalized.testing/runTest(kotlin.coroutines/SuspendFunction1) // com.apollographql.cache.normalized.testing/runTest|runTest(kotlin.coroutines.SuspendFunction1){}[0] + +// Targets: [js, wasmJs] +final fun com.apollographql.cache.normalized.testing/runTest(kotlin.coroutines/SuspendFunction1 = ..., kotlin.coroutines/SuspendFunction1 = ..., kotlin.coroutines/SuspendFunction1): kotlinx.coroutines.test.internal/JsPromiseInterfaceForTesting // com.apollographql.cache.normalized.testing/runTest|runTest(kotlin.coroutines.SuspendFunction1;kotlin.coroutines.SuspendFunction1;kotlin.coroutines.SuspendFunction1){}[0] + +// Targets: [js, wasmJs] +final fun com.apollographql.cache.normalized.testing/runTest(kotlin.coroutines/SuspendFunction1): kotlinx.coroutines.test.internal/JsPromiseInterfaceForTesting // com.apollographql.cache.normalized.testing/runTest|runTest(kotlin.coroutines.SuspendFunction1){}[0] diff --git a/test-utils/build.gradle.kts b/test-utils/build.gradle.kts index 2a4bca78..d6936bd9 100644 --- a/test-utils/build.gradle.kts +++ b/test-utils/build.gradle.kts @@ -14,9 +14,15 @@ kotlin { sourceSets { getByName("commonMain") { dependencies { + api(libs.kotlinx.coroutines.test) api(project(":normalized-cache-incubating")) implementation(libs.kotlin.test) } } + getByName("jsMain") { + dependencies { + api(libs.okio.nodefilesystem) + } + } } } diff --git a/test-utils/src/appleMain/kotlin/com/apollographql/cache/normalized/testing/currentThreadId.apple.kt b/test-utils/src/appleMain/kotlin/com/apollographql/cache/normalized/testing/currentThreadId.apple.kt new file mode 100644 index 00000000..d33e63a5 --- /dev/null +++ b/test-utils/src/appleMain/kotlin/com/apollographql/cache/normalized/testing/currentThreadId.apple.kt @@ -0,0 +1,9 @@ +package com.apollographql.cache.normalized.testing + +import kotlinx.cinterop.ExperimentalForeignApi +import platform.posix.pthread_self + +@OptIn(ExperimentalForeignApi::class) +actual fun currentThreadId(): String { + return pthread_self()?.rawValue.toString() +} diff --git a/test-utils/src/appleMain/kotlin/com/apollographql/cache/normalized/testing/platform.apple.kt b/test-utils/src/appleMain/kotlin/com/apollographql/cache/normalized/testing/platform.apple.kt new file mode 100644 index 00000000..0be80ac8 --- /dev/null +++ b/test-utils/src/appleMain/kotlin/com/apollographql/cache/normalized/testing/platform.apple.kt @@ -0,0 +1,9 @@ +@file:Suppress("DEPRECATION") + +package com.apollographql.cache.normalized.testing + +/** + * The current platform. This is used from tests because Double.toString() doesn't behave the same on JS and other platforms. + * Prefer more specific functions like `assertMainThreadOnNative` when possible instead of checking the platform. + */ +actual fun platform() = Platform.Native diff --git a/test-utils/src/appleMain/kotlin/com/apollographql/cache/normalized/testing/readFile.apple.kt b/test-utils/src/appleMain/kotlin/com/apollographql/cache/normalized/testing/readFile.apple.kt new file mode 100644 index 00000000..ae3a502c --- /dev/null +++ b/test-utils/src/appleMain/kotlin/com/apollographql/cache/normalized/testing/readFile.apple.kt @@ -0,0 +1,5 @@ +package com.apollographql.cache.normalized.testing + +actual fun shouldUpdateTestFixtures(): Boolean = false + +actual val testsPath: String = "../" diff --git a/test-utils/src/commonMain/kotlin/com/apollographql/cache/normalized/testing/FilesystemCommon.kt b/test-utils/src/commonMain/kotlin/com/apollographql/cache/normalized/testing/FilesystemCommon.kt new file mode 100644 index 00000000..17ec45ec --- /dev/null +++ b/test-utils/src/commonMain/kotlin/com/apollographql/cache/normalized/testing/FilesystemCommon.kt @@ -0,0 +1,32 @@ +@file:JvmName("-FileSystemCommon") + +package com.apollographql.cache.normalized.testing + +import com.apollographql.apollo.api.json.JsonReader +import com.apollographql.apollo.api.json.jsonReader +import okio.Path +import okio.Path.Companion.toPath +import okio.buffer +import kotlin.jvm.JvmName + + +private fun String.toTestsPath(): Path { + @Suppress("DEPRECATION") + return testsPath.toPath().resolve(this.toPath()) +} + +/** + * @param path: the path to the file, from the "tests" directory + */ +fun pathToUtf8(path: String): String { + @Suppress("DEPRECATION") + return HostFileSystem.openReadOnly(path.toTestsPath()).source().buffer().readUtf8() +} + +/** + * @param path: the path to the file, from the "tests" directory + */ +fun pathToJsonReader(path: String): JsonReader { + @Suppress("DEPRECATION") + return HostFileSystem.openReadOnly(path.toTestsPath()).source().buffer().jsonReader() +} diff --git a/test-utils/src/commonMain/kotlin/com/apollographql/cache/normalized/testing/channels.kt b/test-utils/src/commonMain/kotlin/com/apollographql/cache/normalized/testing/channels.kt new file mode 100644 index 00000000..a52728a4 --- /dev/null +++ b/test-utils/src/commonMain/kotlin/com/apollographql/cache/normalized/testing/channels.kt @@ -0,0 +1,20 @@ +package com.apollographql.cache.normalized.testing + +import kotlinx.coroutines.TimeoutCancellationException +import kotlinx.coroutines.channels.Channel +import kotlinx.coroutines.withTimeout + +suspend fun Channel.awaitElement(timeoutMillis: Long = 30000) = withTimeout(timeoutMillis) { + receive() +} + +suspend fun Channel.assertNoElement(timeoutMillis: Long = 300): Unit { + try { + withTimeout(timeoutMillis) { + receive() + } + error("An item was unexpectedly received") + } catch (_: TimeoutCancellationException) { + // nothing + } +} diff --git a/test-utils/src/commonMain/kotlin/com/apollographql/cache/normalized/testing/currentThreadId.kt b/test-utils/src/commonMain/kotlin/com/apollographql/cache/normalized/testing/currentThreadId.kt new file mode 100644 index 00000000..940f9d5a --- /dev/null +++ b/test-utils/src/commonMain/kotlin/com/apollographql/cache/normalized/testing/currentThreadId.kt @@ -0,0 +1,3 @@ +package com.apollographql.cache.normalized.testing + +expect fun currentThreadId(): String diff --git a/test-utils/src/commonMain/kotlin/com/apollographql/cache/normalized/testing/platform.kt b/test-utils/src/commonMain/kotlin/com/apollographql/cache/normalized/testing/platform.kt new file mode 100644 index 00000000..00a5eb9d --- /dev/null +++ b/test-utils/src/commonMain/kotlin/com/apollographql/cache/normalized/testing/platform.kt @@ -0,0 +1,12 @@ +@file:Suppress("DEPRECATION") + +package com.apollographql.cache.normalized.testing + +enum class Platform { + Jvm, + Native, + Js, + WasmJs +} + +expect fun platform(): Platform diff --git a/test-utils/src/commonMain/kotlin/com/apollographql/cache/normalized/testing/readFile.kt b/test-utils/src/commonMain/kotlin/com/apollographql/cache/normalized/testing/readFile.kt new file mode 100644 index 00000000..00746f70 --- /dev/null +++ b/test-utils/src/commonMain/kotlin/com/apollographql/cache/normalized/testing/readFile.kt @@ -0,0 +1,17 @@ +package com.apollographql.cache.normalized.testing + +import okio.FileSystem + +/** + * The host filesystem + */ +expect val HostFileSystem: FileSystem + +expect fun shouldUpdateTestFixtures(): Boolean + +/** + * The path to the "tests" directory. This assumes all tests are run from a predictable place relative to "tests" + * We need this for JS tests where the CWD is not properly set at the beginning of tests + */ +expect val testsPath: String + diff --git a/test-utils/src/commonMain/kotlin/com/apollographql/cache/normalized/testing/runTest.kt b/test-utils/src/commonMain/kotlin/com/apollographql/cache/normalized/testing/runTest.kt new file mode 100644 index 00000000..ec4ec746 --- /dev/null +++ b/test-utils/src/commonMain/kotlin/com/apollographql/cache/normalized/testing/runTest.kt @@ -0,0 +1,24 @@ +package com.apollographql.cache.normalized.testing + +import kotlinx.coroutines.CoroutineScope +import kotlinx.coroutines.Dispatchers +import kotlinx.coroutines.test.TestResult +import kotlinx.coroutines.withContext + +fun runTest( + block: suspend CoroutineScope.() -> Unit, +) = runTest({}, {}, block) + +fun runTest( + before: suspend CoroutineScope.() -> Unit = {}, + after: suspend CoroutineScope.() -> Unit = {}, + block: suspend CoroutineScope.() -> Unit, +): TestResult { + return kotlinx.coroutines.test.runTest { + withContext(Dispatchers.Default.limitedParallelism(1)) { + before() + block() + after() + } + } +} diff --git a/test-utils/src/concurrentMain/kotlin/com/apollographql/cache/normalized/testing/readFile.concurrent.kt b/test-utils/src/concurrentMain/kotlin/com/apollographql/cache/normalized/testing/readFile.concurrent.kt new file mode 100644 index 00000000..66fffad8 --- /dev/null +++ b/test-utils/src/concurrentMain/kotlin/com/apollographql/cache/normalized/testing/readFile.concurrent.kt @@ -0,0 +1,10 @@ +package com.apollographql.cache.normalized.testing + +import okio.FileSystem +import okio.SYSTEM + +/** + * The host filesystem + */ +actual val HostFileSystem: FileSystem + get() = FileSystem.SYSTEM diff --git a/test-utils/src/jsCommonMain/kotlin/com/apollographql/cache/normalized/testing/currentThreadId.jsCommon.kt b/test-utils/src/jsCommonMain/kotlin/com/apollographql/cache/normalized/testing/currentThreadId.jsCommon.kt new file mode 100644 index 00000000..7df2f18d --- /dev/null +++ b/test-utils/src/jsCommonMain/kotlin/com/apollographql/cache/normalized/testing/currentThreadId.jsCommon.kt @@ -0,0 +1,5 @@ +package com.apollographql.cache.normalized.testing + +actual fun currentThreadId(): String { + return "js" +} diff --git a/test-utils/src/jsMain/kotlin/com/apollographql/cache/normalized/testing/platform.js.kt b/test-utils/src/jsMain/kotlin/com/apollographql/cache/normalized/testing/platform.js.kt new file mode 100644 index 00000000..41f51b50 --- /dev/null +++ b/test-utils/src/jsMain/kotlin/com/apollographql/cache/normalized/testing/platform.js.kt @@ -0,0 +1,10 @@ +@file:Suppress("DEPRECATION") + +package com.apollographql.cache.normalized.testing + +/** + * The current platform. This is used from tests because Double.toString() doesn't behave the same on JS and other platforms. + * Prefer more specific functions like `assertMainThreadOnNative` when possible instead of checking the platform. + */ +actual fun platform() = Platform.Js + diff --git a/test-utils/src/jsMain/kotlin/com/apollographql/cache/normalized/testing/readFile.js.kt b/test-utils/src/jsMain/kotlin/com/apollographql/cache/normalized/testing/readFile.js.kt new file mode 100644 index 00000000..9da61d51 --- /dev/null +++ b/test-utils/src/jsMain/kotlin/com/apollographql/cache/normalized/testing/readFile.js.kt @@ -0,0 +1,11 @@ +package com.apollographql.cache.normalized.testing + +import okio.FileSystem +import okio.NodeJsFileSystem + +actual val HostFileSystem: FileSystem = NodeJsFileSystem + +actual fun shouldUpdateTestFixtures(): Boolean = false + +// Workaround for https://youtrack.jetbrains.com/issue/KT-49125 +actual val testsPath: String = "../../../../../tests/" diff --git a/test-utils/src/jvmCommonMain/kotlin/com/apollographql/cache/normalized/testing/currentThreadId.jvmCommon.kt b/test-utils/src/jvmCommonMain/kotlin/com/apollographql/cache/normalized/testing/currentThreadId.jvmCommon.kt new file mode 100644 index 00000000..bc8dcb5b --- /dev/null +++ b/test-utils/src/jvmCommonMain/kotlin/com/apollographql/cache/normalized/testing/currentThreadId.jvmCommon.kt @@ -0,0 +1,6 @@ +package com.apollographql.cache.normalized.testing + +actual fun currentThreadId(): String { + @Suppress("DEPRECATION") + return Thread.currentThread().id.toString() +} diff --git a/test-utils/src/jvmCommonMain/kotlin/com/apollographql/cache/normalized/testing/platform.jvmCommon.kt b/test-utils/src/jvmCommonMain/kotlin/com/apollographql/cache/normalized/testing/platform.jvmCommon.kt new file mode 100644 index 00000000..4a2ce611 --- /dev/null +++ b/test-utils/src/jvmCommonMain/kotlin/com/apollographql/cache/normalized/testing/platform.jvmCommon.kt @@ -0,0 +1,9 @@ +@file:Suppress("DEPRECATION") + +package com.apollographql.cache.normalized.testing + +/** + * The current platform. This is used from tests because Double.toString() doesn't behave the same on JS and other platforms. + * Prefer more specific functions like `assertMainThreadOnNative` when possible instead of checking the platform. + */ +actual fun platform() = Platform.Jvm diff --git a/test-utils/src/jvmMain/kotlin/com/apollographql/cache/normalized/testing/readFile.jvm.kt b/test-utils/src/jvmMain/kotlin/com/apollographql/cache/normalized/testing/readFile.jvm.kt new file mode 100644 index 00000000..0bb2759a --- /dev/null +++ b/test-utils/src/jvmMain/kotlin/com/apollographql/cache/normalized/testing/readFile.jvm.kt @@ -0,0 +1,14 @@ +package com.apollographql.cache.normalized.testing + +actual fun shouldUpdateTestFixtures(): Boolean { + if (System.getenv("updateTestFixtures") != null) { + return true + } + + return when (System.getProperty("updateTestFixtures")?.trim()) { + "on", "true", "1" -> true + else -> false + } +} + +actual val testsPath: String = "../" diff --git a/test-utils/src/wasmJsMain/kotlin/com/apollographql/cache/normalized/testing/platform.wasmJs.kt b/test-utils/src/wasmJsMain/kotlin/com/apollographql/cache/normalized/testing/platform.wasmJs.kt new file mode 100644 index 00000000..458afd15 --- /dev/null +++ b/test-utils/src/wasmJsMain/kotlin/com/apollographql/cache/normalized/testing/platform.wasmJs.kt @@ -0,0 +1,9 @@ +@file:Suppress("DEPRECATION") + +package com.apollographql.cache.normalized.testing + +/** + * The current platform. This is used from tests because Double.toString() doesn't behave the same on JS and other platforms. + * Prefer more specific functions like `assertMainThreadOnNative` when possible instead of checking the platform. + */ +actual fun platform() = Platform.WasmJs diff --git a/test-utils/src/wasmJsMain/kotlin/com/apollographql/cache/normalized/testing/readFile.wasmJs.kt b/test-utils/src/wasmJsMain/kotlin/com/apollographql/cache/normalized/testing/readFile.wasmJs.kt new file mode 100644 index 00000000..ea0b2e2a --- /dev/null +++ b/test-utils/src/wasmJsMain/kotlin/com/apollographql/cache/normalized/testing/readFile.wasmJs.kt @@ -0,0 +1,20 @@ +package com.apollographql.cache.normalized.testing + +import okio.FileSystem + +/** + * The host filesystem + */ +actual val HostFileSystem: FileSystem + get() = TODO("Not yet implemented") + +actual fun shouldUpdateTestFixtures(): Boolean { + TODO("Not yet implemented") +} + +/** + * The path to the "tests" directory. This assumes all tests are run from a predictable place relative to "tests" + * We need this for JS tests where the CWD is not properly set at the beginning of tests + */ +actual val testsPath: String + get() = TODO("Not yet implemented") diff --git a/tests/cache-control/build.gradle.kts b/tests/cache-control/build.gradle.kts index 29804102..5f3f0593 100644 --- a/tests/cache-control/build.gradle.kts +++ b/tests/cache-control/build.gradle.kts @@ -21,11 +21,10 @@ kotlin { getByName("commonTest") { dependencies { - implementation(libs.apollo.testing.support) + implementation("com.apollographql.cache:test-utils") implementation(libs.apollo.mockserver) implementation(libs.kotlin.test) implementation(libs.turbine) - implementation("com.apollographql.cache:test-utils") } } diff --git a/tests/cache-control/src/commonTest/kotlin/ClientAndServerSideCacheControlTest.kt b/tests/cache-control/src/commonTest/kotlin/ClientAndServerSideCacheControlTest.kt index 7a796555..c6e354d1 100644 --- a/tests/cache-control/src/commonTest/kotlin/ClientAndServerSideCacheControlTest.kt +++ b/tests/cache-control/src/commonTest/kotlin/ClientAndServerSideCacheControlTest.kt @@ -5,7 +5,6 @@ import com.apollographql.apollo.ApolloClient import com.apollographql.apollo.api.ApolloResponse import com.apollographql.apollo.api.Query import com.apollographql.apollo.exception.CacheMissException -import com.apollographql.apollo.testing.internal.runTest import com.apollographql.cache.normalized.FetchPolicy import com.apollographql.cache.normalized.api.CacheControlCacheResolver import com.apollographql.cache.normalized.api.GlobalMaxAgeProvider @@ -22,6 +21,7 @@ import com.apollographql.cache.normalized.memory.MemoryCacheFactory import com.apollographql.cache.normalized.normalizedCache import com.apollographql.cache.normalized.sql.SqlNormalizedCacheFactory import com.apollographql.cache.normalized.storeExpirationDate +import com.apollographql.cache.normalized.testing.runTest import com.apollographql.mockserver.MockResponse import com.apollographql.mockserver.MockServer import com.apollographql.mockserver.enqueueString diff --git a/tests/cache-control/src/commonTest/kotlin/ClientSideCacheControlTest.kt b/tests/cache-control/src/commonTest/kotlin/ClientSideCacheControlTest.kt index fca56942..e511719c 100644 --- a/tests/cache-control/src/commonTest/kotlin/ClientSideCacheControlTest.kt +++ b/tests/cache-control/src/commonTest/kotlin/ClientSideCacheControlTest.kt @@ -3,7 +3,6 @@ package test import com.apollographql.apollo.ApolloClient import com.apollographql.apollo.exception.CacheMissException import com.apollographql.apollo.mpp.currentTimeMillis -import com.apollographql.apollo.testing.internal.runTest import com.apollographql.cache.normalized.FetchPolicy import com.apollographql.cache.normalized.api.ApolloCacheHeaders import com.apollographql.cache.normalized.api.CacheControlCacheResolver @@ -20,6 +19,7 @@ import com.apollographql.cache.normalized.maxStale import com.apollographql.cache.normalized.memory.MemoryCacheFactory import com.apollographql.cache.normalized.normalizedCache import com.apollographql.cache.normalized.sql.SqlNormalizedCacheFactory +import com.apollographql.cache.normalized.testing.runTest import programmatic.GetCompanyQuery import programmatic.GetUserAdminQuery import programmatic.GetUserEmailQuery diff --git a/tests/cache-control/src/commonTest/kotlin/DoNotStoreTest.kt b/tests/cache-control/src/commonTest/kotlin/DoNotStoreTest.kt index e9dc040b..d5e28151 100644 --- a/tests/cache-control/src/commonTest/kotlin/DoNotStoreTest.kt +++ b/tests/cache-control/src/commonTest/kotlin/DoNotStoreTest.kt @@ -7,7 +7,6 @@ import com.apollographql.apollo.api.Error import com.apollographql.apollo.api.Operation import com.apollographql.apollo.interceptor.ApolloInterceptor import com.apollographql.apollo.interceptor.ApolloInterceptorChain -import com.apollographql.apollo.testing.internal.runTest import com.apollographql.cache.normalized.FetchPolicy import com.apollographql.cache.normalized.api.CacheHeaders import com.apollographql.cache.normalized.api.CacheKey @@ -26,6 +25,7 @@ import com.apollographql.cache.normalized.sql.SqlNormalizedCacheFactory import com.apollographql.cache.normalized.testing.append import com.apollographql.cache.normalized.testing.assertErrorsEquals import com.apollographql.cache.normalized.testing.keyToString +import com.apollographql.cache.normalized.testing.runTest import com.apollographql.mockserver.MockServer import com.apollographql.mockserver.enqueueString import donotstore.GetUserQuery diff --git a/tests/cache-control/src/commonTest/kotlin/ServerSideCacheControlTest.kt b/tests/cache-control/src/commonTest/kotlin/ServerSideCacheControlTest.kt index 777e0913..e3dc07ee 100644 --- a/tests/cache-control/src/commonTest/kotlin/ServerSideCacheControlTest.kt +++ b/tests/cache-control/src/commonTest/kotlin/ServerSideCacheControlTest.kt @@ -3,7 +3,6 @@ package test import com.apollographql.apollo.ApolloClient import com.apollographql.apollo.api.ApolloResponse import com.apollographql.apollo.exception.CacheMissException -import com.apollographql.apollo.testing.internal.runTest import com.apollographql.cache.normalized.FetchPolicy import com.apollographql.cache.normalized.api.CacheControlCacheResolver import com.apollographql.cache.normalized.api.NormalizedCacheFactory @@ -14,6 +13,7 @@ import com.apollographql.cache.normalized.memory.MemoryCacheFactory import com.apollographql.cache.normalized.normalizedCache import com.apollographql.cache.normalized.sql.SqlNormalizedCacheFactory import com.apollographql.cache.normalized.storeExpirationDate +import com.apollographql.cache.normalized.testing.runTest import com.apollographql.mockserver.MockResponse import com.apollographql.mockserver.MockServer import programmatic.GetUserQuery diff --git a/tests/cache-variables-arguments/build.gradle.kts b/tests/cache-variables-arguments/build.gradle.kts index 491614a0..56960f0e 100644 --- a/tests/cache-variables-arguments/build.gradle.kts +++ b/tests/cache-variables-arguments/build.gradle.kts @@ -22,7 +22,7 @@ kotlin { getByName("commonTest") { dependencies { implementation(libs.kotlin.test) - implementation(libs.apollo.testing.support) + implementation("com.apollographql.cache:test-utils") } } } diff --git a/tests/cache-variables-arguments/src/commonTest/kotlin/test/IncludeTest.kt b/tests/cache-variables-arguments/src/commonTest/kotlin/test/IncludeTest.kt index 9f709192..7fe5b2ee 100644 --- a/tests/cache-variables-arguments/src/commonTest/kotlin/test/IncludeTest.kt +++ b/tests/cache-variables-arguments/src/commonTest/kotlin/test/IncludeTest.kt @@ -2,12 +2,12 @@ package test import cache.include.GetUserQuery import com.apollographql.apollo.ApolloClient -import com.apollographql.apollo.testing.internal.runTest import com.apollographql.cache.normalized.FetchPolicy import com.apollographql.cache.normalized.apolloStore import com.apollographql.cache.normalized.fetchPolicy import com.apollographql.cache.normalized.memory.MemoryCacheFactory import com.apollographql.cache.normalized.normalizedCache +import com.apollographql.cache.normalized.testing.runTest import kotlin.test.Test import kotlin.test.assertEquals diff --git a/tests/defer/build.gradle.kts b/tests/defer/build.gradle.kts index abc60ab5..78861f55 100644 --- a/tests/defer/build.gradle.kts +++ b/tests/defer/build.gradle.kts @@ -22,9 +22,8 @@ kotlin { findByName("commonTest")?.apply { dependencies { implementation(libs.kotlin.test) - implementation(libs.apollo.testing.support) - implementation(libs.apollo.mockserver) implementation("com.apollographql.cache:test-utils") + implementation(libs.apollo.mockserver) } } } diff --git a/tests/defer/src/commonTest/kotlin/test/DeferNormalizedCacheTest.kt b/tests/defer/src/commonTest/kotlin/test/DeferNormalizedCacheTest.kt index a5bef974..061262b5 100644 --- a/tests/defer/src/commonTest/kotlin/test/DeferNormalizedCacheTest.kt +++ b/tests/defer/src/commonTest/kotlin/test/DeferNormalizedCacheTest.kt @@ -11,7 +11,6 @@ import com.apollographql.apollo.exception.ApolloHttpException import com.apollographql.apollo.exception.ApolloNetworkException import com.apollographql.apollo.exception.CacheMissException import com.apollographql.apollo.network.NetworkTransport -import com.apollographql.apollo.testing.internal.runTest import com.apollographql.cache.normalized.ApolloStore import com.apollographql.cache.normalized.FetchPolicy import com.apollographql.cache.normalized.api.CacheHeaders @@ -21,8 +20,11 @@ import com.apollographql.cache.normalized.fetchPolicy import com.apollographql.cache.normalized.memory.MemoryCacheFactory import com.apollographql.cache.normalized.optimisticUpdates import com.apollographql.cache.normalized.store +import com.apollographql.cache.normalized.testing.Platform import com.apollographql.cache.normalized.testing.append import com.apollographql.cache.normalized.testing.keyToString +import com.apollographql.cache.normalized.testing.platform +import com.apollographql.cache.normalized.testing.runTest import com.apollographql.mockserver.MockServer import com.apollographql.mockserver.assertNoRequest import com.apollographql.mockserver.awaitRequest @@ -532,7 +534,7 @@ class DeferNormalizedCacheTest { @Test fun intermediatePayloadsAreCached() = runTest(before = { setUp() }, after = { tearDown() }) { @Suppress("DEPRECATION") - if (com.apollographql.apollo.testing.platform() == com.apollographql.apollo.testing.Platform.Js) { + if (platform() == Platform.Js) { // TODO For now chunked is not supported on JS - remove this check when it is return@runTest } diff --git a/tests/garbage-collection/build.gradle.kts b/tests/garbage-collection/build.gradle.kts index a70bbd27..fa250e09 100644 --- a/tests/garbage-collection/build.gradle.kts +++ b/tests/garbage-collection/build.gradle.kts @@ -21,10 +21,9 @@ kotlin { getByName("commonTest") { dependencies { - implementation(libs.apollo.testing.support) + implementation("com.apollographql.cache:test-utils") implementation(libs.apollo.mockserver) implementation(libs.kotlin.test) - implementation("com.apollographql.cache:test-utils") } } } diff --git a/tests/garbage-collection/src/commonTest/kotlin/DanglingReferencesTest.kt b/tests/garbage-collection/src/commonTest/kotlin/DanglingReferencesTest.kt index 1ec8329b..c9cfed79 100644 --- a/tests/garbage-collection/src/commonTest/kotlin/DanglingReferencesTest.kt +++ b/tests/garbage-collection/src/commonTest/kotlin/DanglingReferencesTest.kt @@ -1,7 +1,6 @@ package test import com.apollographql.apollo.ApolloClient -import com.apollographql.apollo.testing.internal.runTest import com.apollographql.cache.normalized.ApolloStore import com.apollographql.cache.normalized.FetchPolicy import com.apollographql.cache.normalized.allRecords @@ -13,6 +12,7 @@ import com.apollographql.cache.normalized.sql.SqlNormalizedCacheFactory import com.apollographql.cache.normalized.store import com.apollographql.cache.normalized.testing.append import com.apollographql.cache.normalized.testing.fieldKey +import com.apollographql.cache.normalized.testing.runTest import com.apollographql.mockserver.MockServer import com.apollographql.mockserver.enqueueString import kotlinx.coroutines.test.TestResult diff --git a/tests/garbage-collection/src/commonTest/kotlin/GarbageCollectTest.kt b/tests/garbage-collection/src/commonTest/kotlin/GarbageCollectTest.kt index f7f10cc6..fe646c1a 100644 --- a/tests/garbage-collection/src/commonTest/kotlin/GarbageCollectTest.kt +++ b/tests/garbage-collection/src/commonTest/kotlin/GarbageCollectTest.kt @@ -1,7 +1,6 @@ package test import com.apollographql.apollo.ApolloClient -import com.apollographql.apollo.testing.internal.runTest import com.apollographql.cache.normalized.ApolloStore import com.apollographql.cache.normalized.FetchPolicy import com.apollographql.cache.normalized.allRecords @@ -15,6 +14,7 @@ import com.apollographql.cache.normalized.sql.SqlNormalizedCacheFactory import com.apollographql.cache.normalized.store import com.apollographql.cache.normalized.testing.append import com.apollographql.cache.normalized.testing.fieldKey +import com.apollographql.cache.normalized.testing.runTest import com.apollographql.mockserver.MockServer import com.apollographql.mockserver.enqueueString import okio.use diff --git a/tests/garbage-collection/src/commonTest/kotlin/ReachableCacheKeysTest.kt b/tests/garbage-collection/src/commonTest/kotlin/ReachableCacheKeysTest.kt index a06f62d6..4c71f5e0 100644 --- a/tests/garbage-collection/src/commonTest/kotlin/ReachableCacheKeysTest.kt +++ b/tests/garbage-collection/src/commonTest/kotlin/ReachableCacheKeysTest.kt @@ -1,7 +1,6 @@ package test import com.apollographql.apollo.ApolloClient -import com.apollographql.apollo.testing.internal.runTest import com.apollographql.cache.normalized.ApolloStore import com.apollographql.cache.normalized.FetchPolicy import com.apollographql.cache.normalized.allRecords @@ -13,6 +12,7 @@ import com.apollographql.cache.normalized.removeUnreachableRecords import com.apollographql.cache.normalized.sql.SqlNormalizedCacheFactory import com.apollographql.cache.normalized.store import com.apollographql.cache.normalized.storeReceivedDate +import com.apollographql.cache.normalized.testing.runTest import com.apollographql.mockserver.MockServer import com.apollographql.mockserver.enqueueString import okio.use diff --git a/tests/garbage-collection/src/commonTest/kotlin/StaleFieldsTest.kt b/tests/garbage-collection/src/commonTest/kotlin/StaleFieldsTest.kt index 7333848c..13f22189 100644 --- a/tests/garbage-collection/src/commonTest/kotlin/StaleFieldsTest.kt +++ b/tests/garbage-collection/src/commonTest/kotlin/StaleFieldsTest.kt @@ -2,7 +2,6 @@ package test import com.apollographql.apollo.ApolloClient import com.apollographql.apollo.mpp.currentTimeMillis -import com.apollographql.apollo.testing.internal.runTest import com.apollographql.cache.normalized.ApolloStore import com.apollographql.cache.normalized.FetchPolicy import com.apollographql.cache.normalized.allRecords @@ -19,6 +18,7 @@ import com.apollographql.cache.normalized.sql.SqlNormalizedCacheFactory import com.apollographql.cache.normalized.store import com.apollographql.cache.normalized.testing.append import com.apollographql.cache.normalized.testing.fieldKey +import com.apollographql.cache.normalized.testing.runTest import com.apollographql.mockserver.MockServer import com.apollographql.mockserver.enqueueString import okio.use diff --git a/tests/include-skip-operation-based/build.gradle.kts b/tests/include-skip-operation-based/build.gradle.kts index 4203cb6a..dcb409ad 100644 --- a/tests/include-skip-operation-based/build.gradle.kts +++ b/tests/include-skip-operation-based/build.gradle.kts @@ -24,7 +24,7 @@ kotlin { findByName("commonTest")?.apply { dependencies { implementation(libs.kotlin.test) - implementation(libs.apollo.testing.support) + implementation("com.apollographql.cache:test-utils") implementation(libs.apollo.mockserver) } } diff --git a/tests/include-skip-operation-based/src/commonTest/kotlin/IncludeTest.kt b/tests/include-skip-operation-based/src/commonTest/kotlin/IncludeTest.kt index d932a362..4273f5e2 100644 --- a/tests/include-skip-operation-based/src/commonTest/kotlin/IncludeTest.kt +++ b/tests/include-skip-operation-based/src/commonTest/kotlin/IncludeTest.kt @@ -4,9 +4,9 @@ import com.apollographql.apollo.api.Operation import com.apollographql.apollo.api.Optional import com.apollographql.apollo.api.json.MapJsonReader import com.apollographql.apollo.api.toApolloResponse -import com.apollographql.apollo.testing.internal.runTest import com.apollographql.cache.normalized.api.CacheKey import com.apollographql.cache.normalized.internal.normalized +import com.apollographql.cache.normalized.testing.runTest import com.example.GetCatIncludeVariableWithDefaultQuery import com.example.SkipFragmentWithDefaultToFalseQuery import com.example.type.buildCat diff --git a/tests/migration/build.gradle.kts b/tests/migration/build.gradle.kts index a141f796..1ef4144c 100644 --- a/tests/migration/build.gradle.kts +++ b/tests/migration/build.gradle.kts @@ -23,7 +23,7 @@ kotlin { getByName("commonTest") { dependencies { - implementation(libs.apollo.testing.support) + implementation("com.apollographql.cache:test-utils") implementation(libs.apollo.mockserver) implementation(libs.kotlin.test) } diff --git a/tests/migration/src/commonTest/kotlin/MigrationTest.kt b/tests/migration/src/commonTest/kotlin/MigrationTest.kt index 521b3c6a..eeb6c37d 100644 --- a/tests/migration/src/commonTest/kotlin/MigrationTest.kt +++ b/tests/migration/src/commonTest/kotlin/MigrationTest.kt @@ -3,7 +3,6 @@ package test import com.apollographql.apollo.ApolloClient import com.apollographql.apollo.exception.CacheMissException import com.apollographql.apollo.mpp.currentTimeMillis -import com.apollographql.apollo.testing.internal.runTest import com.apollographql.cache.normalized.ApolloStore import com.apollographql.cache.normalized.FetchPolicy import com.apollographql.cache.normalized.api.CacheHeaders @@ -15,6 +14,7 @@ import com.apollographql.cache.normalized.fetchPolicy import com.apollographql.cache.normalized.memory.MemoryCacheFactory import com.apollographql.cache.normalized.sql.SqlNormalizedCacheFactory import com.apollographql.cache.normalized.store +import com.apollographql.cache.normalized.testing.runTest import com.apollographql.mockserver.MockServer import com.apollographql.mockserver.enqueueString import okio.use diff --git a/tests/models-operation-based-with-interfaces/build.gradle.kts b/tests/models-operation-based-with-interfaces/build.gradle.kts index bee92ce3..31690443 100644 --- a/tests/models-operation-based-with-interfaces/build.gradle.kts +++ b/tests/models-operation-based-with-interfaces/build.gradle.kts @@ -23,7 +23,7 @@ kotlin { getByName("commonTest") { dependencies { - implementation(libs.apollo.testing.support) + implementation("com.apollographql.cache:test-utils") implementation(libs.apollo.mockserver) implementation(libs.kotlin.test) } diff --git a/tests/models-operation-based-with-interfaces/src/commonTest/kotlin/Utils.kt b/tests/models-operation-based-with-interfaces/src/commonTest/kotlin/Utils.kt index 37d2c960..d51db620 100644 --- a/tests/models-operation-based-with-interfaces/src/commonTest/kotlin/Utils.kt +++ b/tests/models-operation-based-with-interfaces/src/commonTest/kotlin/Utils.kt @@ -1,4 +1,4 @@ -import com.apollographql.apollo.testing.pathToUtf8 +import com.apollographql.cache.normalized.testing.pathToUtf8 @Suppress("DEPRECATION") fun testFixtureToUtf8(name: String) = pathToUtf8("models-fixtures/json/$name") diff --git a/tests/models-operation-based-with-interfaces/src/commonTest/kotlin/test/BasicTest.kt b/tests/models-operation-based-with-interfaces/src/commonTest/kotlin/test/BasicTest.kt index 2ad98f9b..d0596f1f 100644 --- a/tests/models-operation-based-with-interfaces/src/commonTest/kotlin/test/BasicTest.kt +++ b/tests/models-operation-based-with-interfaces/src/commonTest/kotlin/test/BasicTest.kt @@ -7,13 +7,13 @@ import com.apollographql.apollo.ApolloClient import com.apollographql.apollo.api.ApolloResponse import com.apollographql.apollo.api.Optional import com.apollographql.apollo.api.Query -import com.apollographql.apollo.testing.internal.runTest import com.apollographql.cache.normalized.ApolloStore import com.apollographql.cache.normalized.FetchPolicy import com.apollographql.cache.normalized.api.IdCacheKeyGenerator import com.apollographql.cache.normalized.fetchPolicy import com.apollographql.cache.normalized.memory.MemoryCacheFactory import com.apollographql.cache.normalized.store +import com.apollographql.cache.normalized.testing.runTest import com.apollographql.mockserver.MockServer import com.apollographql.mockserver.enqueueString import testFixtureToUtf8 diff --git a/tests/models-operation-based-with-interfaces/src/commonTest/kotlin/test/StoreTest.kt b/tests/models-operation-based-with-interfaces/src/commonTest/kotlin/test/StoreTest.kt index 829e8138..b1072ac0 100644 --- a/tests/models-operation-based-with-interfaces/src/commonTest/kotlin/test/StoreTest.kt +++ b/tests/models-operation-based-with-interfaces/src/commonTest/kotlin/test/StoreTest.kt @@ -7,12 +7,12 @@ import codegen.models.fragment.HeroWithFriendsFragmentImpl import codegen.models.fragment.HumanWithIdFragment import codegen.models.fragment.HumanWithIdFragmentImpl import com.apollographql.apollo.ApolloClient -import com.apollographql.apollo.testing.internal.runTest import com.apollographql.cache.normalized.ApolloStore import com.apollographql.cache.normalized.api.CacheKey import com.apollographql.cache.normalized.api.IdCacheKeyGenerator import com.apollographql.cache.normalized.memory.MemoryCacheFactory import com.apollographql.cache.normalized.store +import com.apollographql.cache.normalized.testing.runTest import com.apollographql.mockserver.MockServer import com.apollographql.mockserver.enqueueString import testFixtureToUtf8 diff --git a/tests/models-operation-based/build.gradle.kts b/tests/models-operation-based/build.gradle.kts index 06dd0f58..9c731598 100644 --- a/tests/models-operation-based/build.gradle.kts +++ b/tests/models-operation-based/build.gradle.kts @@ -21,7 +21,7 @@ kotlin { getByName("commonTest") { dependencies { - implementation(libs.apollo.testing.support) + implementation("com.apollographql.cache:test-utils") implementation(libs.apollo.mockserver) implementation(libs.kotlin.test) } diff --git a/tests/models-operation-based/src/commonTest/kotlin/Utils.kt b/tests/models-operation-based/src/commonTest/kotlin/Utils.kt index 37d2c960..d51db620 100644 --- a/tests/models-operation-based/src/commonTest/kotlin/Utils.kt +++ b/tests/models-operation-based/src/commonTest/kotlin/Utils.kt @@ -1,4 +1,4 @@ -import com.apollographql.apollo.testing.pathToUtf8 +import com.apollographql.cache.normalized.testing.pathToUtf8 @Suppress("DEPRECATION") fun testFixtureToUtf8(name: String) = pathToUtf8("models-fixtures/json/$name") diff --git a/tests/models-operation-based/src/commonTest/kotlin/test/BasicTest.kt b/tests/models-operation-based/src/commonTest/kotlin/test/BasicTest.kt index 2ad98f9b..d0596f1f 100644 --- a/tests/models-operation-based/src/commonTest/kotlin/test/BasicTest.kt +++ b/tests/models-operation-based/src/commonTest/kotlin/test/BasicTest.kt @@ -7,13 +7,13 @@ import com.apollographql.apollo.ApolloClient import com.apollographql.apollo.api.ApolloResponse import com.apollographql.apollo.api.Optional import com.apollographql.apollo.api.Query -import com.apollographql.apollo.testing.internal.runTest import com.apollographql.cache.normalized.ApolloStore import com.apollographql.cache.normalized.FetchPolicy import com.apollographql.cache.normalized.api.IdCacheKeyGenerator import com.apollographql.cache.normalized.fetchPolicy import com.apollographql.cache.normalized.memory.MemoryCacheFactory import com.apollographql.cache.normalized.store +import com.apollographql.cache.normalized.testing.runTest import com.apollographql.mockserver.MockServer import com.apollographql.mockserver.enqueueString import testFixtureToUtf8 diff --git a/tests/models-operation-based/src/commonTest/kotlin/test/StoreTest.kt b/tests/models-operation-based/src/commonTest/kotlin/test/StoreTest.kt index 5c500a81..a2f0ade8 100644 --- a/tests/models-operation-based/src/commonTest/kotlin/test/StoreTest.kt +++ b/tests/models-operation-based/src/commonTest/kotlin/test/StoreTest.kt @@ -7,12 +7,12 @@ import codegen.models.fragment.HeroWithFriendsFragmentImpl import codegen.models.fragment.HumanWithIdFragment import codegen.models.fragment.HumanWithIdFragmentImpl import com.apollographql.apollo.ApolloClient -import com.apollographql.apollo.testing.internal.runTest import com.apollographql.cache.normalized.ApolloStore import com.apollographql.cache.normalized.api.CacheKey import com.apollographql.cache.normalized.api.IdCacheKeyGenerator import com.apollographql.cache.normalized.memory.MemoryCacheFactory import com.apollographql.cache.normalized.store +import com.apollographql.cache.normalized.testing.runTest import com.apollographql.mockserver.MockServer import com.apollographql.mockserver.enqueueString import testFixtureToUtf8 diff --git a/tests/models-response-based/build.gradle.kts b/tests/models-response-based/build.gradle.kts index 0eff709d..56a5cf9d 100644 --- a/tests/models-response-based/build.gradle.kts +++ b/tests/models-response-based/build.gradle.kts @@ -21,7 +21,7 @@ kotlin { getByName("commonTest") { dependencies { - implementation(libs.apollo.testing.support) + implementation("com.apollographql.cache:test-utils") implementation(libs.apollo.mockserver) implementation(libs.kotlin.test) } diff --git a/tests/models-response-based/src/commonTest/kotlin/Utils.kt b/tests/models-response-based/src/commonTest/kotlin/Utils.kt index 37d2c960..d51db620 100644 --- a/tests/models-response-based/src/commonTest/kotlin/Utils.kt +++ b/tests/models-response-based/src/commonTest/kotlin/Utils.kt @@ -1,4 +1,4 @@ -import com.apollographql.apollo.testing.pathToUtf8 +import com.apollographql.cache.normalized.testing.pathToUtf8 @Suppress("DEPRECATION") fun testFixtureToUtf8(name: String) = pathToUtf8("models-fixtures/json/$name") diff --git a/tests/models-response-based/src/commonTest/kotlin/test/BasicTest.kt b/tests/models-response-based/src/commonTest/kotlin/test/BasicTest.kt index 797b1961..ed9b252f 100644 --- a/tests/models-response-based/src/commonTest/kotlin/test/BasicTest.kt +++ b/tests/models-response-based/src/commonTest/kotlin/test/BasicTest.kt @@ -12,13 +12,13 @@ import com.apollographql.apollo.ApolloClient import com.apollographql.apollo.api.ApolloResponse import com.apollographql.apollo.api.Optional import com.apollographql.apollo.api.Query -import com.apollographql.apollo.testing.internal.runTest import com.apollographql.cache.normalized.ApolloStore import com.apollographql.cache.normalized.FetchPolicy import com.apollographql.cache.normalized.api.IdCacheKeyGenerator import com.apollographql.cache.normalized.fetchPolicy import com.apollographql.cache.normalized.memory.MemoryCacheFactory import com.apollographql.cache.normalized.store +import com.apollographql.cache.normalized.testing.runTest import com.apollographql.mockserver.MockServer import com.apollographql.mockserver.enqueueString import testFixtureToUtf8 diff --git a/tests/models-response-based/src/commonTest/kotlin/test/StoreTest.kt b/tests/models-response-based/src/commonTest/kotlin/test/StoreTest.kt index c02b0d84..917b9bb3 100644 --- a/tests/models-response-based/src/commonTest/kotlin/test/StoreTest.kt +++ b/tests/models-response-based/src/commonTest/kotlin/test/StoreTest.kt @@ -8,12 +8,12 @@ import codegen.models.fragment.HeroWithFriendsFragment.Friend.Companion.humanWit import codegen.models.fragment.HeroWithFriendsFragmentImpl import codegen.models.fragment.HumanWithIdFragmentImpl import com.apollographql.apollo.ApolloClient -import com.apollographql.apollo.testing.internal.runTest import com.apollographql.cache.normalized.ApolloStore import com.apollographql.cache.normalized.api.CacheKey import com.apollographql.cache.normalized.api.IdCacheKeyGenerator import com.apollographql.cache.normalized.memory.MemoryCacheFactory import com.apollographql.cache.normalized.store +import com.apollographql.cache.normalized.testing.runTest import com.apollographql.mockserver.MockServer import com.apollographql.mockserver.enqueueString import testFixtureToUtf8 diff --git a/tests/normalization-tests/build.gradle.kts b/tests/normalization-tests/build.gradle.kts index 93204aec..79bacc89 100644 --- a/tests/normalization-tests/build.gradle.kts +++ b/tests/normalization-tests/build.gradle.kts @@ -21,7 +21,7 @@ kotlin { getByName("commonTest") { dependencies { - implementation(libs.apollo.testing.support) + implementation("com.apollographql.cache:test-utils") implementation(libs.apollo.mockserver) implementation(libs.kotlin.test) } diff --git a/tests/normalization-tests/src/commonTest/kotlin/com/example/NormalizationTest.kt b/tests/normalization-tests/src/commonTest/kotlin/com/example/NormalizationTest.kt index f3023331..3272c1a3 100644 --- a/tests/normalization-tests/src/commonTest/kotlin/com/example/NormalizationTest.kt +++ b/tests/normalization-tests/src/commonTest/kotlin/com/example/NormalizationTest.kt @@ -4,7 +4,6 @@ import com.apollographql.apollo.ApolloClient import com.apollographql.apollo.api.CustomScalarAdapters import com.apollographql.apollo.api.json.jsonReader import com.apollographql.apollo.api.toApolloResponse -import com.apollographql.apollo.testing.internal.runTest import com.apollographql.cache.normalized.ApolloStore import com.apollographql.cache.normalized.FetchPolicy import com.apollographql.cache.normalized.api.CacheKey @@ -19,6 +18,7 @@ import com.apollographql.cache.normalized.fetchPolicy import com.apollographql.cache.normalized.memory.MemoryCacheFactory import com.apollographql.cache.normalized.normalizedCache import com.apollographql.cache.normalized.store +import com.apollographql.cache.normalized.testing.runTest import com.apollographql.mockserver.MockServer import com.apollographql.mockserver.enqueueString import com.example.one.Issue2818Query diff --git a/tests/normalized-cache/build.gradle.kts b/tests/normalized-cache/build.gradle.kts index babe8e4c..633ff35c 100644 --- a/tests/normalized-cache/build.gradle.kts +++ b/tests/normalized-cache/build.gradle.kts @@ -28,10 +28,10 @@ kotlin { getByName("commonTest") { dependencies { implementation(libs.apollo.testing.support) + implementation("com.apollographql.cache:test-utils") implementation(libs.apollo.mockserver) implementation(libs.kotlin.test) implementation(libs.turbine) - implementation("com.apollographql.cache:test-utils") } } diff --git a/tests/normalized-cache/src/commonTest/kotlin/BasicTest.kt b/tests/normalized-cache/src/commonTest/kotlin/BasicTest.kt index a7add521..4cfc164d 100644 --- a/tests/normalized-cache/src/commonTest/kotlin/BasicTest.kt +++ b/tests/normalized-cache/src/commonTest/kotlin/BasicTest.kt @@ -3,13 +3,13 @@ package test import com.apollographql.apollo.ApolloClient import com.apollographql.apollo.api.ApolloResponse import com.apollographql.apollo.api.Query -import com.apollographql.apollo.testing.internal.runTest import com.apollographql.cache.normalized.ApolloStore import com.apollographql.cache.normalized.FetchPolicy import com.apollographql.cache.normalized.api.IdCacheKeyGenerator import com.apollographql.cache.normalized.fetchPolicy import com.apollographql.cache.normalized.memory.MemoryCacheFactory import com.apollographql.cache.normalized.store +import com.apollographql.cache.normalized.testing.runTest import com.apollographql.mockserver.MockServer import com.apollographql.mockserver.enqueueString import httpcache.AllPlanetsQuery diff --git a/tests/normalized-cache/src/commonTest/kotlin/CacheFlagsTest.kt b/tests/normalized-cache/src/commonTest/kotlin/CacheFlagsTest.kt index 43c6f44d..b8f2b1ea 100644 --- a/tests/normalized-cache/src/commonTest/kotlin/CacheFlagsTest.kt +++ b/tests/normalized-cache/src/commonTest/kotlin/CacheFlagsTest.kt @@ -10,7 +10,6 @@ import com.apollographql.apollo.interceptor.ApolloInterceptor import com.apollographql.apollo.interceptor.ApolloInterceptorChain import com.apollographql.apollo.testing.QueueTestNetworkTransport import com.apollographql.apollo.testing.enqueueTestResponse -import com.apollographql.apollo.testing.internal.runTest import com.apollographql.cache.normalized.ApolloStore import com.apollographql.cache.normalized.FetchPolicy import com.apollographql.cache.normalized.api.ApolloCacheHeaders @@ -20,6 +19,7 @@ import com.apollographql.cache.normalized.doNotStore import com.apollographql.cache.normalized.fetchPolicy import com.apollographql.cache.normalized.memory.MemoryCacheFactory import com.apollographql.cache.normalized.store +import com.apollographql.cache.normalized.testing.runTest import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.map import normalizer.HeroNameQuery diff --git a/tests/normalized-cache/src/commonTest/kotlin/CacheResolverTest.kt b/tests/normalized-cache/src/commonTest/kotlin/CacheResolverTest.kt index 7aecbf74..b000da08 100644 --- a/tests/normalized-cache/src/commonTest/kotlin/CacheResolverTest.kt +++ b/tests/normalized-cache/src/commonTest/kotlin/CacheResolverTest.kt @@ -1,13 +1,13 @@ package test import com.apollographql.apollo.ApolloClient -import com.apollographql.apollo.testing.internal.runTest import com.apollographql.cache.normalized.ApolloStore import com.apollographql.cache.normalized.api.CacheResolver import com.apollographql.cache.normalized.api.DefaultCacheResolver import com.apollographql.cache.normalized.api.ResolverContext import com.apollographql.cache.normalized.memory.MemoryCacheFactory import com.apollographql.cache.normalized.store +import com.apollographql.cache.normalized.testing.runTest import normalizer.HeroNameQuery import kotlin.test.Test import kotlin.test.assertEquals diff --git a/tests/normalized-cache/src/commonTest/kotlin/CancelTest.kt b/tests/normalized-cache/src/commonTest/kotlin/CancelTest.kt index 543619bd..3514befb 100644 --- a/tests/normalized-cache/src/commonTest/kotlin/CancelTest.kt +++ b/tests/normalized-cache/src/commonTest/kotlin/CancelTest.kt @@ -1,11 +1,11 @@ package test import com.apollographql.apollo.ApolloClient -import com.apollographql.apollo.testing.internal.runTest import com.apollographql.cache.normalized.FetchPolicy import com.apollographql.cache.normalized.fetchPolicy import com.apollographql.cache.normalized.memory.MemoryCacheFactory import com.apollographql.cache.normalized.normalizedCache +import com.apollographql.cache.normalized.testing.runTest import com.apollographql.mockserver.MockServer import com.apollographql.mockserver.enqueueString import kotlinx.coroutines.delay diff --git a/tests/normalized-cache/src/commonTest/kotlin/ExceptionsTest.kt b/tests/normalized-cache/src/commonTest/kotlin/ExceptionsTest.kt index 09c09f6e..b84cf316 100644 --- a/tests/normalized-cache/src/commonTest/kotlin/ExceptionsTest.kt +++ b/tests/normalized-cache/src/commonTest/kotlin/ExceptionsTest.kt @@ -3,9 +3,9 @@ package test import com.apollographql.apollo.ApolloClient import com.apollographql.apollo.exception.ApolloHttpException import com.apollographql.apollo.exception.ApolloNetworkException -import com.apollographql.apollo.testing.internal.runTest import com.apollographql.cache.normalized.memory.MemoryCacheFactory import com.apollographql.cache.normalized.normalizedCache +import com.apollographql.cache.normalized.testing.runTest import com.apollographql.mockserver.MockServer import com.apollographql.mockserver.enqueueError import com.apollographql.mockserver.enqueueString diff --git a/tests/normalized-cache/src/commonTest/kotlin/FetchPolicyTest.kt b/tests/normalized-cache/src/commonTest/kotlin/FetchPolicyTest.kt index ca6cd9b3..ad4aff59 100644 --- a/tests/normalized-cache/src/commonTest/kotlin/FetchPolicyTest.kt +++ b/tests/normalized-cache/src/commonTest/kotlin/FetchPolicyTest.kt @@ -18,9 +18,6 @@ import com.apollographql.apollo.exception.CacheMissException import com.apollographql.apollo.exception.JsonEncodingException import com.apollographql.apollo.interceptor.ApolloInterceptor import com.apollographql.apollo.interceptor.ApolloInterceptorChain -import com.apollographql.apollo.testing.assertNoElement -import com.apollographql.apollo.testing.awaitElement -import com.apollographql.apollo.testing.internal.runTest import com.apollographql.cache.normalized.ApolloStore import com.apollographql.cache.normalized.CacheFirstInterceptor import com.apollographql.cache.normalized.CacheOnlyInterceptor @@ -31,7 +28,9 @@ import com.apollographql.cache.normalized.isFromCache import com.apollographql.cache.normalized.memory.MemoryCacheFactory import com.apollographql.cache.normalized.refetchPolicyInterceptor import com.apollographql.cache.normalized.store +import com.apollographql.cache.normalized.testing.assertNoElement import com.apollographql.cache.normalized.testing.fieldKey +import com.apollographql.cache.normalized.testing.runTest import com.apollographql.cache.normalized.watch import com.apollographql.mockserver.MockServer import com.apollographql.mockserver.awaitRequest diff --git a/tests/normalized-cache/src/commonTest/kotlin/IdCacheKeyGeneratorTest.kt b/tests/normalized-cache/src/commonTest/kotlin/IdCacheKeyGeneratorTest.kt index 2d0200f1..31ec420e 100644 --- a/tests/normalized-cache/src/commonTest/kotlin/IdCacheKeyGeneratorTest.kt +++ b/tests/normalized-cache/src/commonTest/kotlin/IdCacheKeyGeneratorTest.kt @@ -3,7 +3,6 @@ package test import com.apollographql.apollo.ApolloClient import com.apollographql.apollo.testing.QueueTestNetworkTransport import com.apollographql.apollo.testing.enqueueTestResponse -import com.apollographql.apollo.testing.internal.runTest import com.apollographql.cache.normalized.ApolloStore import com.apollographql.cache.normalized.FetchPolicy import com.apollographql.cache.normalized.api.IdCacheKeyGenerator @@ -11,6 +10,7 @@ import com.apollographql.cache.normalized.api.IdCacheKeyResolver import com.apollographql.cache.normalized.fetchPolicy import com.apollographql.cache.normalized.memory.MemoryCacheFactory import com.apollographql.cache.normalized.store +import com.apollographql.cache.normalized.testing.runTest import main.GetUser2Query import main.GetUserByIdQuery import main.GetUsersByIDsQuery diff --git a/tests/normalized-cache/src/commonTest/kotlin/JsonScalarTest.kt b/tests/normalized-cache/src/commonTest/kotlin/JsonScalarTest.kt index 93e1d313..f4c85cf3 100644 --- a/tests/normalized-cache/src/commonTest/kotlin/JsonScalarTest.kt +++ b/tests/normalized-cache/src/commonTest/kotlin/JsonScalarTest.kt @@ -2,12 +2,12 @@ package test import com.apollographql.apollo.ApolloClient import com.apollographql.apollo.api.AnyAdapter -import com.apollographql.apollo.testing.internal.runTest import com.apollographql.cache.normalized.ApolloStore import com.apollographql.cache.normalized.FetchPolicy import com.apollographql.cache.normalized.fetchPolicy import com.apollographql.cache.normalized.memory.MemoryCacheFactory import com.apollographql.cache.normalized.store +import com.apollographql.cache.normalized.testing.runTest import com.apollographql.mockserver.MockServer import com.apollographql.mockserver.enqueueString import normalizer.GetJsonScalarQuery diff --git a/tests/normalized-cache/src/commonTest/kotlin/MemoryCacheTest.kt b/tests/normalized-cache/src/commonTest/kotlin/MemoryCacheTest.kt index 22f81e8b..aa78d58a 100644 --- a/tests/normalized-cache/src/commonTest/kotlin/MemoryCacheTest.kt +++ b/tests/normalized-cache/src/commonTest/kotlin/MemoryCacheTest.kt @@ -1,11 +1,11 @@ package test -import com.apollographql.apollo.testing.internal.runTest import com.apollographql.cache.normalized.api.CacheHeaders import com.apollographql.cache.normalized.api.CacheKey import com.apollographql.cache.normalized.api.DefaultRecordMerger import com.apollographql.cache.normalized.api.Record import com.apollographql.cache.normalized.memory.MemoryCache +import com.apollographql.cache.normalized.testing.runTest import kotlinx.coroutines.delay import kotlin.test.Test import kotlin.test.assertEquals diff --git a/tests/normalized-cache/src/commonTest/kotlin/NormalizationTest.kt b/tests/normalized-cache/src/commonTest/kotlin/NormalizationTest.kt index 6cb39c15..2ca0fdee 100644 --- a/tests/normalized-cache/src/commonTest/kotlin/NormalizationTest.kt +++ b/tests/normalized-cache/src/commonTest/kotlin/NormalizationTest.kt @@ -3,11 +3,11 @@ package test import com.apollographql.apollo.ApolloClient import com.apollographql.apollo.testing.QueueTestNetworkTransport import com.apollographql.apollo.testing.enqueueTestResponse -import com.apollographql.apollo.testing.internal.runTest import com.apollographql.cache.normalized.FetchPolicy import com.apollographql.cache.normalized.fetchPolicy import com.apollographql.cache.normalized.memory.MemoryCacheFactory import com.apollographql.cache.normalized.normalizedCache +import com.apollographql.cache.normalized.testing.runTest import main.RepositoryListQuery import kotlin.test.Test import kotlin.test.assertEquals diff --git a/tests/normalized-cache/src/commonTest/kotlin/NormalizedCacheThreadingTest.kt b/tests/normalized-cache/src/commonTest/kotlin/NormalizedCacheThreadingTest.kt index 44ffc5c5..401f4f29 100644 --- a/tests/normalized-cache/src/commonTest/kotlin/NormalizedCacheThreadingTest.kt +++ b/tests/normalized-cache/src/commonTest/kotlin/NormalizedCacheThreadingTest.kt @@ -2,12 +2,12 @@ package test import com.apollographql.apollo.ApolloClient import com.apollographql.apollo.testing.QueueTestNetworkTransport -import com.apollographql.apollo.testing.currentThreadId import com.apollographql.apollo.testing.enqueueTestResponse import com.apollographql.cache.normalized.api.NormalizedCache import com.apollographql.cache.normalized.api.NormalizedCacheFactory import com.apollographql.cache.normalized.memory.MemoryCacheFactory import com.apollographql.cache.normalized.normalizedCache +import com.apollographql.cache.normalized.testing.currentThreadId import kotlinx.coroutines.test.runTest import normalizer.CharacterNameByIdQuery import kotlin.test.Test diff --git a/tests/normalized-cache/src/commonTest/kotlin/OptimisticCacheTest.kt b/tests/normalized-cache/src/commonTest/kotlin/OptimisticCacheTest.kt index 5abe1a68..d42656b3 100644 --- a/tests/normalized-cache/src/commonTest/kotlin/OptimisticCacheTest.kt +++ b/tests/normalized-cache/src/commonTest/kotlin/OptimisticCacheTest.kt @@ -2,8 +2,6 @@ package test import com.apollographql.apollo.ApolloClient import com.apollographql.apollo.api.Optional -import com.apollographql.apollo.testing.awaitElement -import com.apollographql.apollo.testing.internal.runTest import com.apollographql.cache.normalized.ApolloStore import com.apollographql.cache.normalized.FetchPolicy import com.apollographql.cache.normalized.api.CacheKey @@ -13,6 +11,7 @@ import com.apollographql.cache.normalized.memory.MemoryCacheFactory import com.apollographql.cache.normalized.optimisticUpdates import com.apollographql.cache.normalized.refetchPolicy import com.apollographql.cache.normalized.store +import com.apollographql.cache.normalized.testing.runTest import com.apollographql.cache.normalized.watch import com.apollographql.mockserver.MockServer import com.apollographql.mockserver.enqueueString diff --git a/tests/normalized-cache/src/commonTest/kotlin/OtherCacheTest.kt b/tests/normalized-cache/src/commonTest/kotlin/OtherCacheTest.kt index cad1d811..1b2b7d0b 100644 --- a/tests/normalized-cache/src/commonTest/kotlin/OtherCacheTest.kt +++ b/tests/normalized-cache/src/commonTest/kotlin/OtherCacheTest.kt @@ -3,7 +3,6 @@ package test import com.apollographql.apollo.ApolloClient import com.apollographql.apollo.api.composeJsonResponse import com.apollographql.apollo.exception.CacheMissException -import com.apollographql.apollo.testing.internal.runTest import com.apollographql.cache.normalized.ApolloStore import com.apollographql.cache.normalized.FetchPolicy import com.apollographql.cache.normalized.api.CacheKey @@ -13,6 +12,7 @@ import com.apollographql.cache.normalized.fetchPolicy import com.apollographql.cache.normalized.memory.MemoryCacheFactory import com.apollographql.cache.normalized.store import com.apollographql.cache.normalized.testing.keyToString +import com.apollographql.cache.normalized.testing.runTest import com.apollographql.mockserver.MockServer import com.apollographql.mockserver.enqueueString import normalizer.CharacterDetailsQuery diff --git a/tests/normalized-cache/src/commonTest/kotlin/StoreTest.kt b/tests/normalized-cache/src/commonTest/kotlin/StoreTest.kt index 3c36c9bd..fc62374f 100644 --- a/tests/normalized-cache/src/commonTest/kotlin/StoreTest.kt +++ b/tests/normalized-cache/src/commonTest/kotlin/StoreTest.kt @@ -4,7 +4,6 @@ import com.apollographql.apollo.ApolloClient import com.apollographql.apollo.exception.CacheMissException import com.apollographql.apollo.testing.QueueTestNetworkTransport import com.apollographql.apollo.testing.enqueueTestResponse -import com.apollographql.apollo.testing.internal.runTest import com.apollographql.cache.normalized.ApolloStore import com.apollographql.cache.normalized.FetchPolicy import com.apollographql.cache.normalized.api.CacheKey @@ -14,6 +13,7 @@ import com.apollographql.cache.normalized.fetchPolicy import com.apollographql.cache.normalized.isFromCache import com.apollographql.cache.normalized.memory.MemoryCacheFactory import com.apollographql.cache.normalized.store +import com.apollographql.cache.normalized.testing.runTest import normalizer.CharacterNameByIdQuery import normalizer.HeroAndFriendsNamesWithIDsQuery import normalizer.type.Episode diff --git a/tests/normalized-cache/src/commonTest/kotlin/ThreadTests.kt b/tests/normalized-cache/src/commonTest/kotlin/ThreadTests.kt index 29538744..684c1c88 100644 --- a/tests/normalized-cache/src/commonTest/kotlin/ThreadTests.kt +++ b/tests/normalized-cache/src/commonTest/kotlin/ThreadTests.kt @@ -3,11 +3,8 @@ package test import com.apollographql.apollo.ApolloClient -import com.apollographql.apollo.testing.Platform import com.apollographql.apollo.testing.QueueTestNetworkTransport -import com.apollographql.apollo.testing.currentThreadId import com.apollographql.apollo.testing.enqueueTestResponse -import com.apollographql.apollo.testing.platform import com.apollographql.cache.normalized.FetchPolicy import com.apollographql.cache.normalized.api.CacheHeaders import com.apollographql.cache.normalized.api.CacheKey @@ -18,6 +15,9 @@ import com.apollographql.cache.normalized.api.RecordMerger import com.apollographql.cache.normalized.fetchPolicy import com.apollographql.cache.normalized.memory.MemoryCache import com.apollographql.cache.normalized.normalizedCache +import com.apollographql.cache.normalized.testing.Platform +import com.apollographql.cache.normalized.testing.currentThreadId +import com.apollographql.cache.normalized.testing.platform import kotlinx.coroutines.test.runTest import normalizer.HeroNameQuery import kotlin.reflect.KClass diff --git a/tests/normalized-cache/src/commonTest/kotlin/Utils.kt b/tests/normalized-cache/src/commonTest/kotlin/Utils.kt index 70660a3d..b9558258 100644 --- a/tests/normalized-cache/src/commonTest/kotlin/Utils.kt +++ b/tests/normalized-cache/src/commonTest/kotlin/Utils.kt @@ -1,7 +1,7 @@ package test -import com.apollographql.apollo.testing.pathToJsonReader -import com.apollographql.apollo.testing.pathToUtf8 +import com.apollographql.cache.normalized.testing.pathToJsonReader +import com.apollographql.cache.normalized.testing.pathToUtf8 @Suppress("DEPRECATION") fun testFixtureToUtf8(name: String) = pathToUtf8("normalized-cache/testFixtures/$name") diff --git a/tests/normalized-cache/src/commonTest/kotlin/WatcherErrorHandlingTest.kt b/tests/normalized-cache/src/commonTest/kotlin/WatcherErrorHandlingTest.kt index 03b0db08..20165e5a 100644 --- a/tests/normalized-cache/src/commonTest/kotlin/WatcherErrorHandlingTest.kt +++ b/tests/normalized-cache/src/commonTest/kotlin/WatcherErrorHandlingTest.kt @@ -5,8 +5,6 @@ import com.apollographql.apollo.ApolloClient import com.apollographql.apollo.api.ApolloResponse import com.apollographql.apollo.exception.ApolloHttpException import com.apollographql.apollo.exception.CacheMissException -import com.apollographql.apollo.testing.awaitElement -import com.apollographql.apollo.testing.internal.runTest import com.apollographql.cache.normalized.ApolloStore import com.apollographql.cache.normalized.FetchPolicy import com.apollographql.cache.normalized.api.IdCacheKeyGenerator @@ -14,6 +12,7 @@ import com.apollographql.cache.normalized.fetchPolicy import com.apollographql.cache.normalized.memory.MemoryCacheFactory import com.apollographql.cache.normalized.refetchPolicy import com.apollographql.cache.normalized.store +import com.apollographql.cache.normalized.testing.runTest import com.apollographql.cache.normalized.watch import com.apollographql.mockserver.MockServer import com.apollographql.mockserver.enqueueError diff --git a/tests/normalized-cache/src/commonTest/kotlin/WatcherTest.kt b/tests/normalized-cache/src/commonTest/kotlin/WatcherTest.kt index 6ac9cf3a..aa93c918 100644 --- a/tests/normalized-cache/src/commonTest/kotlin/WatcherTest.kt +++ b/tests/normalized-cache/src/commonTest/kotlin/WatcherTest.kt @@ -9,7 +9,6 @@ import com.apollographql.apollo.exception.CacheMissException import com.apollographql.apollo.testing.QueueTestNetworkTransport import com.apollographql.apollo.testing.enqueueTestNetworkError import com.apollographql.apollo.testing.enqueueTestResponse -import com.apollographql.apollo.testing.internal.runTest import com.apollographql.cache.normalized.ApolloStore import com.apollographql.cache.normalized.FetchPolicy import com.apollographql.cache.normalized.api.IdCacheKeyGenerator @@ -18,6 +17,7 @@ import com.apollographql.cache.normalized.memory.MemoryCacheFactory import com.apollographql.cache.normalized.normalizedCache import com.apollographql.cache.normalized.refetchPolicy import com.apollographql.cache.normalized.store +import com.apollographql.cache.normalized.testing.runTest import com.apollographql.cache.normalized.watch import com.apollographql.mockserver.MockResponse import com.apollographql.mockserver.MockServer diff --git a/tests/normalized-cache/src/commonTest/kotlin/circular/CircularCacheReadTest.kt b/tests/normalized-cache/src/commonTest/kotlin/circular/CircularCacheReadTest.kt index dce29384..0b01fcb7 100644 --- a/tests/normalized-cache/src/commonTest/kotlin/circular/CircularCacheReadTest.kt +++ b/tests/normalized-cache/src/commonTest/kotlin/circular/CircularCacheReadTest.kt @@ -1,10 +1,9 @@ package test.circular import circular.GetUserQuery -import com.apollographql.apollo.api.CustomScalarAdapters -import com.apollographql.apollo.testing.internal.runTest import com.apollographql.cache.normalized.ApolloStore import com.apollographql.cache.normalized.memory.MemoryCacheFactory +import com.apollographql.cache.normalized.testing.runTest import kotlin.test.Test import kotlin.test.assertEquals @@ -30,7 +29,7 @@ class CircularCacheReadTest { ) store.writeOperation(operation, data) - val result = store.readOperation(operation, customScalarAdapters = CustomScalarAdapters.Empty).data!! + val result = store.readOperation(operation).data!! assertEquals("42", result.user.friend.id) } } diff --git a/tests/normalized-cache/src/commonTest/kotlin/declarativecache/DeclarativeCacheTest.kt b/tests/normalized-cache/src/commonTest/kotlin/declarativecache/DeclarativeCacheTest.kt index 8278084c..bc2b4308 100644 --- a/tests/normalized-cache/src/commonTest/kotlin/declarativecache/DeclarativeCacheTest.kt +++ b/tests/normalized-cache/src/commonTest/kotlin/declarativecache/DeclarativeCacheTest.kt @@ -1,13 +1,12 @@ package test.declarativecache -import com.apollographql.apollo.api.CustomScalarAdapters -import com.apollographql.apollo.testing.internal.runTest import com.apollographql.cache.normalized.ApolloStore import com.apollographql.cache.normalized.api.CacheKey import com.apollographql.cache.normalized.api.CacheResolver import com.apollographql.cache.normalized.api.FieldPolicyCacheResolver import com.apollographql.cache.normalized.api.ResolverContext import com.apollographql.cache.normalized.memory.MemoryCacheFactory +import com.apollographql.cache.normalized.testing.runTest import declarativecache.GetAuthorQuery import declarativecache.GetBookQuery import declarativecache.GetBooksQuery @@ -36,7 +35,7 @@ class DeclarativeCacheTest { store.writeOperation(otherOperation, otherData) // Get the "promo" book again, the title must be updated - val data = store.readOperation(promoOperation, CustomScalarAdapters.Empty).data!! + val data = store.readOperation(promoOperation).data!! assertEquals("Other", data.promoBook?.title) } @@ -56,7 +55,7 @@ class DeclarativeCacheTest { store.writeOperation(otherOperation, otherData) // Get the "promo" library again, the address must be updated - val data = store.readOperation(promoOperation, CustomScalarAdapters.Empty).data!! + val data = store.readOperation(promoOperation).data!! assertEquals("OtherAddress", data.promoLibrary?.address) } @@ -70,7 +69,7 @@ class DeclarativeCacheTest { store.writeOperation(bookQuery1, bookData1) val bookQuery2 = GetBookQuery("42") - val bookData2 = store.readOperation(bookQuery2, CustomScalarAdapters.Empty).data!! + val bookData2 = store.readOperation(bookQuery2).data!! assertEquals("Promo", bookData2.book?.title) @@ -86,7 +85,7 @@ class DeclarativeCacheTest { store.writeOperation(authorQuery1, authorData1) val authorQuery2 = GetAuthorQuery("Pierre", "Bordage") - val authorData2 = store.readOperation(authorQuery2, CustomScalarAdapters.Empty).data!! + val authorData2 = store.readOperation(authorQuery2).data!! assertEquals("Pierre", authorData2.author?.firstName) assertEquals("Bordage", authorData2.author?.lastName) @@ -117,13 +116,13 @@ class DeclarativeCacheTest { store.writeOperation(promoOperation, GetPromoBookQuery.Data(GetPromoBookQuery.PromoBook("Title4", "4", "Book"))) var operation = GetBooksQuery(listOf("4", "1")) - var data = store.readOperation(operation, CustomScalarAdapters.Empty).data!! + var data = store.readOperation(operation).data!! assertEquals("Title4", data.books.get(0).title) assertEquals("Title1", data.books.get(1).title) operation = GetBooksQuery(listOf("3")) - data = store.readOperation(operation, CustomScalarAdapters.Empty).data!! + data = store.readOperation(operation).data!! assertEquals("Title3", data.books.get(0).title) } diff --git a/tests/normalized-cache/src/commonTest/kotlin/fragmentnormalizer/FragmentNormalizerTest.kt b/tests/normalized-cache/src/commonTest/kotlin/fragmentnormalizer/FragmentNormalizerTest.kt index 4805f18f..8f8e6ba4 100644 --- a/tests/normalized-cache/src/commonTest/kotlin/fragmentnormalizer/FragmentNormalizerTest.kt +++ b/tests/normalized-cache/src/commonTest/kotlin/fragmentnormalizer/FragmentNormalizerTest.kt @@ -1,8 +1,6 @@ package test.fragmentnormalizer import com.apollographql.apollo.ApolloClient -import com.apollographql.apollo.api.CustomScalarAdapters -import com.apollographql.apollo.testing.internal.runTest import com.apollographql.cache.normalized.api.CacheKey import com.apollographql.cache.normalized.api.IdCacheKeyGenerator import com.apollographql.cache.normalized.apolloStore @@ -10,6 +8,7 @@ import com.apollographql.cache.normalized.internal.normalized import com.apollographql.cache.normalized.memory.MemoryCacheFactory import com.apollographql.cache.normalized.normalizedCache import com.apollographql.cache.normalized.testing.append +import com.apollographql.cache.normalized.testing.runTest import fragmentnormalizer.fragment.ConversationFragment import fragmentnormalizer.fragment.ConversationFragmentImpl import kotlin.test.Test @@ -66,14 +65,12 @@ class FragmentNormalizerTest { ConversationFragmentImpl(), CacheKey(fragment1.id), fragment1Read, - CustomScalarAdapters.Empty ) apolloClient.apolloStore.writeFragment( ConversationFragmentImpl(), CacheKey(fragment2.id), fragment2Read, - CustomScalarAdapters.Empty ) fragment1 = apolloClient.apolloStore.readFragment( diff --git a/tests/normalized-cache/src/concurrentTest/kotlin/MemoryCacheOnlyTest.kt b/tests/normalized-cache/src/concurrentTest/kotlin/MemoryCacheOnlyTest.kt index 76c03ef6..a7b10204 100644 --- a/tests/normalized-cache/src/concurrentTest/kotlin/MemoryCacheOnlyTest.kt +++ b/tests/normalized-cache/src/concurrentTest/kotlin/MemoryCacheOnlyTest.kt @@ -2,7 +2,6 @@ import com.apollographql.apollo.ApolloClient import com.apollographql.apollo.exception.CacheMissException import com.apollographql.apollo.testing.QueueTestNetworkTransport import com.apollographql.apollo.testing.enqueueTestResponse -import com.apollographql.apollo.testing.internal.runTest import com.apollographql.cache.normalized.ApolloStore import com.apollographql.cache.normalized.FetchPolicy import com.apollographql.cache.normalized.api.CacheKey @@ -14,6 +13,7 @@ import com.apollographql.cache.normalized.memoryCacheOnly import com.apollographql.cache.normalized.sql.SqlNormalizedCache import com.apollographql.cache.normalized.sql.SqlNormalizedCacheFactory import com.apollographql.cache.normalized.store +import com.apollographql.cache.normalized.testing.runTest import main.GetUserQuery import kotlin.reflect.KClass import kotlin.test.Test diff --git a/tests/normalized-cache/src/jvmTest/kotlin/ApqCacheTest.kt b/tests/normalized-cache/src/jvmTest/kotlin/ApqCacheTest.kt index 67034bc5..1a20c65e 100644 --- a/tests/normalized-cache/src/jvmTest/kotlin/ApqCacheTest.kt +++ b/tests/normalized-cache/src/jvmTest/kotlin/ApqCacheTest.kt @@ -3,9 +3,9 @@ package test import com.apollographql.apollo.ApolloClient import com.apollographql.apollo.api.composeJsonResponse import com.apollographql.apollo.api.http.HttpMethod -import com.apollographql.apollo.testing.internal.runTest import com.apollographql.cache.normalized.memory.MemoryCacheFactory import com.apollographql.cache.normalized.normalizedCache +import com.apollographql.cache.normalized.testing.runTest import com.apollographql.mockserver.MockServer import com.apollographql.mockserver.enqueueString import normalizer.HeroNameQuery diff --git a/tests/normalized-cache/src/jvmTest/kotlin/CacheConcurrencyTest.kt b/tests/normalized-cache/src/jvmTest/kotlin/CacheConcurrencyTest.kt index 22628fd4..b4df802e 100644 --- a/tests/normalized-cache/src/jvmTest/kotlin/CacheConcurrencyTest.kt +++ b/tests/normalized-cache/src/jvmTest/kotlin/CacheConcurrencyTest.kt @@ -3,10 +3,10 @@ package test import com.apollographql.apollo.ApolloClient import com.apollographql.apollo.testing.QueueTestNetworkTransport import com.apollographql.apollo.testing.enqueueTestResponse -import com.apollographql.apollo.testing.internal.runTest import com.apollographql.cache.normalized.ApolloStore import com.apollographql.cache.normalized.memory.MemoryCacheFactory import com.apollographql.cache.normalized.store +import com.apollographql.cache.normalized.testing.runTest import kotlinx.coroutines.asCoroutineDispatcher import kotlinx.coroutines.joinAll import kotlinx.coroutines.launch diff --git a/tests/normalized-cache/src/jvmTest/kotlin/CacheMissLoggingInterceptorTest.kt b/tests/normalized-cache/src/jvmTest/kotlin/CacheMissLoggingInterceptorTest.kt index f80e4831..75f53303 100644 --- a/tests/normalized-cache/src/jvmTest/kotlin/CacheMissLoggingInterceptorTest.kt +++ b/tests/normalized-cache/src/jvmTest/kotlin/CacheMissLoggingInterceptorTest.kt @@ -1,7 +1,6 @@ package test import com.apollographql.apollo.ApolloClient -import com.apollographql.apollo.testing.internal.runTest import com.apollographql.cache.normalized.FetchPolicy import com.apollographql.cache.normalized.api.CacheKey import com.apollographql.cache.normalized.fetchPolicy @@ -9,6 +8,7 @@ import com.apollographql.cache.normalized.logCacheMisses import com.apollographql.cache.normalized.memory.MemoryCacheFactory import com.apollographql.cache.normalized.normalizedCache import com.apollographql.cache.normalized.testing.keyToString +import com.apollographql.cache.normalized.testing.runTest import com.apollographql.mockserver.MockServer import com.apollographql.mockserver.enqueueString import normalizer.HeroAppearsInQuery diff --git a/tests/normalized-cache/src/jvmTest/kotlin/WriteToCacheAsynchronouslyTest.kt b/tests/normalized-cache/src/jvmTest/kotlin/WriteToCacheAsynchronouslyTest.kt index 755545fb..56bf959b 100644 --- a/tests/normalized-cache/src/jvmTest/kotlin/WriteToCacheAsynchronouslyTest.kt +++ b/tests/normalized-cache/src/jvmTest/kotlin/WriteToCacheAsynchronouslyTest.kt @@ -1,12 +1,12 @@ package test import com.apollographql.apollo.ApolloClient -import com.apollographql.apollo.testing.internal.runTest import com.apollographql.cache.normalized.ApolloStore import com.apollographql.cache.normalized.api.CacheHeaders import com.apollographql.cache.normalized.api.CacheKey import com.apollographql.cache.normalized.memory.MemoryCacheFactory import com.apollographql.cache.normalized.store +import com.apollographql.cache.normalized.testing.runTest import com.apollographql.cache.normalized.writeToCacheAsynchronously import com.apollographql.mockserver.MockServer import com.apollographql.mockserver.enqueueString diff --git a/tests/number-scalar/build.gradle.kts b/tests/number-scalar/build.gradle.kts index bbefea17..a81248e7 100644 --- a/tests/number-scalar/build.gradle.kts +++ b/tests/number-scalar/build.gradle.kts @@ -22,6 +22,7 @@ kotlin { getByName("commonTest") { dependencies { implementation(libs.apollo.testing.support) + implementation("com.apollographql.cache:test-utils") implementation(libs.kotlin.test) } } diff --git a/tests/number-scalar/src/commonTest/kotlin/test/NumberTest.kt b/tests/number-scalar/src/commonTest/kotlin/test/NumberTest.kt index a4bd8dc1..28a410c6 100644 --- a/tests/number-scalar/src/commonTest/kotlin/test/NumberTest.kt +++ b/tests/number-scalar/src/commonTest/kotlin/test/NumberTest.kt @@ -8,11 +8,11 @@ import com.apollographql.apollo.api.json.JsonReader import com.apollographql.apollo.api.json.JsonWriter import com.apollographql.apollo.testing.QueueTestNetworkTransport import com.apollographql.apollo.testing.enqueueTestResponse -import com.apollographql.apollo.testing.internal.runTest import com.apollographql.cache.normalized.FetchPolicy import com.apollographql.cache.normalized.fetchPolicy import com.apollographql.cache.normalized.memory.MemoryCacheFactory import com.apollographql.cache.normalized.normalizedCache +import com.apollographql.cache.normalized.testing.runTest import com.example.GetNumberQuery import okio.use import kotlin.test.Test diff --git a/tests/optimistic-data/build.gradle.kts b/tests/optimistic-data/build.gradle.kts index 6934a6fc..22b9a45a 100644 --- a/tests/optimistic-data/build.gradle.kts +++ b/tests/optimistic-data/build.gradle.kts @@ -22,7 +22,7 @@ kotlin { getByName("commonTest") { dependencies { implementation(libs.kotlin.test) - implementation(libs.apollo.testing.support) + implementation("com.apollographql.cache:test-utils") implementation(libs.apollo.mockserver) implementation(libs.turbine) } diff --git a/tests/optimistic-data/src/jvmTest/kotlin/test/OptimisticDataTest.kt b/tests/optimistic-data/src/jvmTest/kotlin/test/OptimisticDataTest.kt index 3381d95a..2b61ef53 100644 --- a/tests/optimistic-data/src/jvmTest/kotlin/test/OptimisticDataTest.kt +++ b/tests/optimistic-data/src/jvmTest/kotlin/test/OptimisticDataTest.kt @@ -2,10 +2,10 @@ package test import app.cash.turbine.test import com.apollographql.apollo.ApolloClient -import com.apollographql.apollo.testing.internal.runTest import com.apollographql.cache.normalized.memory.MemoryCacheFactory import com.apollographql.cache.normalized.normalizedCache import com.apollographql.cache.normalized.optimisticUpdates +import com.apollographql.cache.normalized.testing.runTest import com.apollographql.cache.normalized.watch import com.apollographql.mockserver.MockResponse import com.apollographql.mockserver.MockServer diff --git a/tests/pagination/build.gradle.kts b/tests/pagination/build.gradle.kts index f6838eee..e2b4fa92 100644 --- a/tests/pagination/build.gradle.kts +++ b/tests/pagination/build.gradle.kts @@ -24,6 +24,7 @@ kotlin { getByName("commonTest") { dependencies { implementation(libs.apollo.testing.support) + implementation("com.apollographql.cache:test-utils") implementation(libs.apollo.mockserver) implementation(libs.kotlin.test) } diff --git a/tests/pagination/src/commonTest/kotlin/ConnectionPaginationTest.kt b/tests/pagination/src/commonTest/kotlin/ConnectionPaginationTest.kt index c11d70aa..e42d466f 100644 --- a/tests/pagination/src/commonTest/kotlin/ConnectionPaginationTest.kt +++ b/tests/pagination/src/commonTest/kotlin/ConnectionPaginationTest.kt @@ -2,7 +2,6 @@ package pagination import com.apollographql.apollo.api.Error import com.apollographql.apollo.api.Optional -import com.apollographql.apollo.testing.internal.runTest import com.apollographql.cache.normalized.ApolloStore import com.apollographql.cache.normalized.api.ConnectionMetadataGenerator import com.apollographql.cache.normalized.api.ConnectionRecordMerger @@ -11,6 +10,7 @@ import com.apollographql.cache.normalized.api.NormalizedCacheFactory import com.apollographql.cache.normalized.api.TypePolicyCacheKeyGenerator import com.apollographql.cache.normalized.memory.MemoryCacheFactory import com.apollographql.cache.normalized.sql.SqlNormalizedCacheFactory +import com.apollographql.cache.normalized.testing.runTest import pagination.connection.UsersQuery import pagination.connection.pagination.Pagination import pagination.connection.type.buildPageInfo diff --git a/tests/pagination/src/commonTest/kotlin/ConnectionProgrammaticPaginationTest.kt b/tests/pagination/src/commonTest/kotlin/ConnectionProgrammaticPaginationTest.kt index f20ea377..65511788 100644 --- a/tests/pagination/src/commonTest/kotlin/ConnectionProgrammaticPaginationTest.kt +++ b/tests/pagination/src/commonTest/kotlin/ConnectionProgrammaticPaginationTest.kt @@ -1,7 +1,6 @@ package pagination import com.apollographql.apollo.api.Optional -import com.apollographql.apollo.testing.internal.runTest import com.apollographql.cache.normalized.ApolloStore import com.apollographql.cache.normalized.api.ConnectionEmbeddedFieldsProvider import com.apollographql.cache.normalized.api.ConnectionFieldKeyGenerator @@ -12,6 +11,7 @@ import com.apollographql.cache.normalized.api.NormalizedCacheFactory import com.apollographql.cache.normalized.api.TypePolicyCacheKeyGenerator import com.apollographql.cache.normalized.memory.MemoryCacheFactory import com.apollographql.cache.normalized.sql.SqlNormalizedCacheFactory +import com.apollographql.cache.normalized.testing.runTest import pagination.connectionProgrammatic.UsersQuery import pagination.connectionProgrammatic.type.Query import pagination.connectionProgrammatic.type.UserConnection diff --git a/tests/pagination/src/commonTest/kotlin/ConnectionWithNodesPaginationTest.kt b/tests/pagination/src/commonTest/kotlin/ConnectionWithNodesPaginationTest.kt index 50130b82..43cc0e2c 100644 --- a/tests/pagination/src/commonTest/kotlin/ConnectionWithNodesPaginationTest.kt +++ b/tests/pagination/src/commonTest/kotlin/ConnectionWithNodesPaginationTest.kt @@ -1,7 +1,6 @@ package pagination import com.apollographql.apollo.api.Optional -import com.apollographql.apollo.testing.internal.runTest import com.apollographql.cache.normalized.ApolloStore import com.apollographql.cache.normalized.api.ConnectionMetadataGenerator import com.apollographql.cache.normalized.api.ConnectionRecordMerger @@ -10,6 +9,7 @@ import com.apollographql.cache.normalized.api.NormalizedCacheFactory import com.apollographql.cache.normalized.api.TypePolicyCacheKeyGenerator import com.apollographql.cache.normalized.memory.MemoryCacheFactory import com.apollographql.cache.normalized.sql.SqlNormalizedCacheFactory +import com.apollographql.cache.normalized.testing.runTest import pagination.connectionWithNodes.UsersQuery import pagination.connectionWithNodes.pagination.Pagination import pagination.connectionWithNodes.type.buildPageInfo diff --git a/tests/pagination/src/commonTest/kotlin/CursorBasedPaginationTest.kt b/tests/pagination/src/commonTest/kotlin/CursorBasedPaginationTest.kt index 1449e92a..95ce8023 100644 --- a/tests/pagination/src/commonTest/kotlin/CursorBasedPaginationTest.kt +++ b/tests/pagination/src/commonTest/kotlin/CursorBasedPaginationTest.kt @@ -4,7 +4,6 @@ import com.apollographql.apollo.ApolloClient import com.apollographql.apollo.api.Optional import com.apollographql.apollo.testing.QueueTestNetworkTransport import com.apollographql.apollo.testing.enqueueTestResponse -import com.apollographql.apollo.testing.internal.runTest import com.apollographql.cache.normalized.ApolloStore import com.apollographql.cache.normalized.FetchPolicy import com.apollographql.cache.normalized.api.ConnectionMetadataGenerator @@ -16,6 +15,7 @@ import com.apollographql.cache.normalized.fetchPolicy import com.apollographql.cache.normalized.memory.MemoryCacheFactory import com.apollographql.cache.normalized.normalizedCache import com.apollographql.cache.normalized.sql.SqlNormalizedCacheFactory +import com.apollographql.cache.normalized.testing.runTest import kotlinx.coroutines.flow.toList import pagination.cursorBased.UsersQuery import pagination.cursorBased.type.buildPageInfo diff --git a/tests/pagination/src/commonTest/kotlin/EmbedTest.kt b/tests/pagination/src/commonTest/kotlin/EmbedTest.kt index 6526143a..4263092d 100644 --- a/tests/pagination/src/commonTest/kotlin/EmbedTest.kt +++ b/tests/pagination/src/commonTest/kotlin/EmbedTest.kt @@ -1,7 +1,6 @@ package pagination import com.apollographql.apollo.ApolloClient -import com.apollographql.apollo.testing.internal.runTest import com.apollographql.cache.normalized.api.CacheKey import com.apollographql.cache.normalized.api.CacheKeyGenerator import com.apollographql.cache.normalized.api.CacheKeyGeneratorContext @@ -9,6 +8,7 @@ import com.apollographql.cache.normalized.apolloStore import com.apollographql.cache.normalized.internal.normalized import com.apollographql.cache.normalized.memory.MemoryCacheFactory import com.apollographql.cache.normalized.normalizedCache +import com.apollographql.cache.normalized.testing.runTest import embed.GetHeroQuery import kotlin.test.Test import kotlin.test.assertEquals diff --git a/tests/pagination/src/commonTest/kotlin/OffsetBasedWithArrayPaginationTest.kt b/tests/pagination/src/commonTest/kotlin/OffsetBasedWithArrayPaginationTest.kt index 69925d93..b5789422 100644 --- a/tests/pagination/src/commonTest/kotlin/OffsetBasedWithArrayPaginationTest.kt +++ b/tests/pagination/src/commonTest/kotlin/OffsetBasedWithArrayPaginationTest.kt @@ -2,7 +2,6 @@ package pagination import com.apollographql.apollo.api.Optional import com.apollographql.apollo.api.json.ApolloJsonElement -import com.apollographql.apollo.testing.internal.runTest import com.apollographql.cache.normalized.ApolloStore import com.apollographql.cache.normalized.api.FieldPolicyCacheResolver import com.apollographql.cache.normalized.api.FieldRecordMerger @@ -12,6 +11,7 @@ import com.apollographql.cache.normalized.api.NormalizedCacheFactory import com.apollographql.cache.normalized.api.TypePolicyCacheKeyGenerator import com.apollographql.cache.normalized.memory.MemoryCacheFactory import com.apollographql.cache.normalized.sql.SqlNormalizedCacheFactory +import com.apollographql.cache.normalized.testing.runTest import pagination.offsetBasedWithArray.UsersQuery import pagination.offsetBasedWithArray.type.buildUser import kotlin.math.max diff --git a/tests/pagination/src/commonTest/kotlin/OffsetBasedWithPageAndInputPaginationTest.kt b/tests/pagination/src/commonTest/kotlin/OffsetBasedWithPageAndInputPaginationTest.kt index 07b0bd70..1ad53c95 100644 --- a/tests/pagination/src/commonTest/kotlin/OffsetBasedWithPageAndInputPaginationTest.kt +++ b/tests/pagination/src/commonTest/kotlin/OffsetBasedWithPageAndInputPaginationTest.kt @@ -5,7 +5,6 @@ import com.apollographql.apollo.api.CompiledField import com.apollographql.apollo.api.Executable import com.apollographql.apollo.api.Optional import com.apollographql.apollo.api.json.ApolloJsonElement -import com.apollographql.apollo.testing.internal.runTest import com.apollographql.cache.normalized.ApolloStore import com.apollographql.cache.normalized.api.DefaultFieldKeyGenerator import com.apollographql.cache.normalized.api.FieldKeyContext @@ -18,6 +17,7 @@ import com.apollographql.cache.normalized.api.NormalizedCacheFactory import com.apollographql.cache.normalized.api.TypePolicyCacheKeyGenerator import com.apollographql.cache.normalized.memory.MemoryCacheFactory import com.apollographql.cache.normalized.sql.SqlNormalizedCacheFactory +import com.apollographql.cache.normalized.testing.runTest import pagination.offsetBasedWithPageAndInput.UsersQuery import pagination.offsetBasedWithPageAndInput.type.buildUser import pagination.offsetBasedWithPageAndInput.type.buildUserPage diff --git a/tests/pagination/src/commonTest/kotlin/OffsetBasedWithPagePaginationTest.kt b/tests/pagination/src/commonTest/kotlin/OffsetBasedWithPagePaginationTest.kt index bcc3724e..ed2bdfdc 100644 --- a/tests/pagination/src/commonTest/kotlin/OffsetBasedWithPagePaginationTest.kt +++ b/tests/pagination/src/commonTest/kotlin/OffsetBasedWithPagePaginationTest.kt @@ -2,7 +2,6 @@ package pagination import com.apollographql.apollo.api.Optional import com.apollographql.apollo.api.json.ApolloJsonElement -import com.apollographql.apollo.testing.internal.runTest import com.apollographql.cache.normalized.ApolloStore import com.apollographql.cache.normalized.api.CacheKey import com.apollographql.cache.normalized.api.FieldPolicyCacheResolver @@ -14,6 +13,7 @@ import com.apollographql.cache.normalized.api.Record import com.apollographql.cache.normalized.api.TypePolicyCacheKeyGenerator import com.apollographql.cache.normalized.memory.MemoryCacheFactory import com.apollographql.cache.normalized.sql.SqlNormalizedCacheFactory +import com.apollographql.cache.normalized.testing.runTest import pagination.offsetBasedWithPage.UsersQuery import pagination.offsetBasedWithPage.type.buildUser import pagination.offsetBasedWithPage.type.buildUserPage diff --git a/tests/partial-results/build.gradle.kts b/tests/partial-results/build.gradle.kts index 5941d46c..d8739c61 100644 --- a/tests/partial-results/build.gradle.kts +++ b/tests/partial-results/build.gradle.kts @@ -21,10 +21,9 @@ kotlin { getByName("commonTest") { dependencies { - implementation(libs.apollo.testing.support) + implementation("com.apollographql.cache:test-utils") implementation(libs.apollo.mockserver) implementation(libs.kotlin.test) - implementation("com.apollographql.cache:test-utils") } } diff --git a/tests/partial-results/src/commonTest/kotlin/test/CachePartialResultTest.kt b/tests/partial-results/src/commonTest/kotlin/test/CachePartialResultTest.kt index faf87012..3d4e80e9 100644 --- a/tests/partial-results/src/commonTest/kotlin/test/CachePartialResultTest.kt +++ b/tests/partial-results/src/commonTest/kotlin/test/CachePartialResultTest.kt @@ -7,7 +7,6 @@ import com.apollographql.apollo.api.Error import com.apollographql.apollo.api.Operation import com.apollographql.apollo.interceptor.ApolloInterceptor import com.apollographql.apollo.interceptor.ApolloInterceptorChain -import com.apollographql.apollo.testing.internal.runTest import com.apollographql.cache.normalized.ApolloStore import com.apollographql.cache.normalized.FetchPolicy import com.apollographql.cache.normalized.api.CacheControlCacheResolver @@ -29,6 +28,7 @@ import com.apollographql.cache.normalized.storeReceivedDate import com.apollographql.cache.normalized.testing.append import com.apollographql.cache.normalized.testing.assertErrorsEquals import com.apollographql.cache.normalized.testing.keyToString +import com.apollographql.cache.normalized.testing.runTest import com.apollographql.mockserver.MockServer import com.apollographql.mockserver.enqueueString import kotlinx.coroutines.flow.Flow diff --git a/tests/schema-changes/build.gradle.kts b/tests/schema-changes/build.gradle.kts index c9c9ace6..dcb544a5 100644 --- a/tests/schema-changes/build.gradle.kts +++ b/tests/schema-changes/build.gradle.kts @@ -22,7 +22,7 @@ kotlin { getByName("commonTest") { dependencies { implementation(libs.kotlin.test) - implementation(libs.apollo.testing.support) + implementation("com.apollographql.cache:test-utils") implementation(libs.apollo.mockserver) implementation(libs.turbine) } diff --git a/tests/schema-changes/src/commonTest/kotlin/test/SchemaChanges.kt b/tests/schema-changes/src/commonTest/kotlin/test/SchemaChanges.kt index 3d28741a..7c74398b 100644 --- a/tests/schema-changes/src/commonTest/kotlin/test/SchemaChanges.kt +++ b/tests/schema-changes/src/commonTest/kotlin/test/SchemaChanges.kt @@ -2,9 +2,9 @@ package test import com.apollographql.apollo.api.CustomScalarAdapters import com.apollographql.apollo.api.json.jsonReader -import com.apollographql.apollo.testing.internal.runTest import com.apollographql.cache.normalized.api.TypePolicyCacheKeyGenerator import com.apollographql.cache.normalized.internal.normalized +import com.apollographql.cache.normalized.testing.runTest import okio.Buffer import schema.changes.GetFieldQuery import kotlin.test.Test diff --git a/tests/store-errors/build.gradle.kts b/tests/store-errors/build.gradle.kts index 0a79e85e..26bd1e5f 100644 --- a/tests/store-errors/build.gradle.kts +++ b/tests/store-errors/build.gradle.kts @@ -21,10 +21,9 @@ kotlin { getByName("commonTest") { dependencies { - implementation(libs.apollo.testing.support) + implementation("com.apollographql.cache:test-utils") implementation(libs.apollo.mockserver) implementation(libs.kotlin.test) - implementation("com.apollographql.cache:test-utils") } } diff --git a/tests/store-errors/src/commonTest/kotlin/test/StoreErrorsTest.kt b/tests/store-errors/src/commonTest/kotlin/test/StoreErrorsTest.kt index b37213e8..21294545 100644 --- a/tests/store-errors/src/commonTest/kotlin/test/StoreErrorsTest.kt +++ b/tests/store-errors/src/commonTest/kotlin/test/StoreErrorsTest.kt @@ -8,7 +8,6 @@ import com.apollographql.apollo.api.Error import com.apollographql.apollo.api.Operation import com.apollographql.apollo.interceptor.ApolloInterceptor import com.apollographql.apollo.interceptor.ApolloInterceptorChain -import com.apollographql.apollo.testing.internal.runTest import com.apollographql.cache.normalized.ApolloStore import com.apollographql.cache.normalized.FetchPolicy import com.apollographql.cache.normalized.api.CacheKey @@ -22,6 +21,7 @@ import com.apollographql.cache.normalized.memory.MemoryCacheFactory import com.apollographql.cache.normalized.sql.SqlNormalizedCacheFactory import com.apollographql.cache.normalized.store import com.apollographql.cache.normalized.testing.assertErrorsEquals +import com.apollographql.cache.normalized.testing.runTest import com.apollographql.mockserver.MockServer import com.apollographql.mockserver.enqueueString import kotlinx.coroutines.flow.Flow