All Downloads are FREE. Search and download functionalities are using the official Maven repository.

appleMain.com.apollographql.apollo3.testing.internal.runTest.kt Maven / Gradle / Ivy

There is a newer version: 4.0.0-beta.7
Show newest version
package com.apollographql.apollo3.testing.internal

import com.apollographql.apollo3.annotations.ApolloInternal
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.ExperimentalCoroutinesApi
import kotlinx.coroutines.runBlocking
import kotlin.coroutines.CoroutineContext

@ApolloInternal
@OptIn(ExperimentalCoroutinesApi::class)
actual fun runTest(
    skipDelays: Boolean,
    context: CoroutineContext,
    before: suspend CoroutineScope.() -> Unit,
    after: suspend CoroutineScope.() -> Unit,
    block: suspend CoroutineScope.() -> Unit,
) {
  if (skipDelays) {
    kotlinx.coroutines.test.runTest(context) {
      before()
      try {
        block()
      } finally {
        after()
      }
    }
  } else {
    runBlocking(context) {
      before()
      try {
        block()
      } finally {
        after()
      }
    }
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy