diff options
Diffstat (limited to 'merchant-lib/src/test')
-rw-r--r-- | merchant-lib/src/test/java/net/taler/merchantlib/MerchantApiTest.kt | 20 |
1 files changed, 11 insertions, 9 deletions
diff --git a/merchant-lib/src/test/java/net/taler/merchantlib/MerchantApiTest.kt b/merchant-lib/src/test/java/net/taler/merchantlib/MerchantApiTest.kt index f9f5e87..992af6f 100644 --- a/merchant-lib/src/test/java/net/taler/merchantlib/MerchantApiTest.kt +++ b/merchant-lib/src/test/java/net/taler/merchantlib/MerchantApiTest.kt @@ -17,7 +17,9 @@ package net.taler.merchantlib import io.ktor.http.HttpStatusCode.Companion.NotFound -import kotlinx.coroutines.runBlocking +import kotlinx.coroutines.ExperimentalCoroutinesApi +import kotlinx.coroutines.test.TestCoroutineDispatcher +import kotlinx.coroutines.test.runBlockingTest import net.taler.common.Amount import net.taler.common.ContractProduct import net.taler.common.ContractTerms @@ -28,9 +30,10 @@ import org.junit.Assert.assertEquals import org.junit.Assert.assertTrue import org.junit.Test +@ExperimentalCoroutinesApi class MerchantApiTest { - private val api = MerchantApi(httpClient) + private val api = MerchantApi(httpClient, TestCoroutineDispatcher()) private val merchantConfig = MerchantConfig( baseUrl = "http://example.net/", instance = "testInstance", @@ -39,7 +42,7 @@ class MerchantApiTest { private val orderId = "orderIdFoo" @Test - fun testGetConfig() = runBlocking { + fun testGetConfig() = runBlockingTest { httpClient.giveJsonResponse("https://backend.int.taler.net/config") { """ { @@ -54,7 +57,7 @@ class MerchantApiTest { } @Test - fun testPostOrder() = runBlocking { + fun testPostOrder() = runBlockingTest { val product = ContractProduct( productId = "foo", description = "bar", @@ -111,7 +114,7 @@ class MerchantApiTest { } @Test - fun testCheckOrder() = runBlocking { + fun testCheckOrder() = runBlockingTest { val unpaidResponse = CheckPaymentResponse.Unpaid(false, "http://taler.net/foo") httpClient.giveJsonResponse("http://example.net/instances/testInstance/private/orders/$orderId") { """{ @@ -140,7 +143,7 @@ class MerchantApiTest { } @Test - fun testDeleteOrder() = runBlocking { + fun testDeleteOrder() = runBlockingTest { httpClient.giveJsonResponse("http://example.net/instances/testInstance/private/orders/$orderId") { "{}" } @@ -163,7 +166,7 @@ class MerchantApiTest { } @Test - fun testGetOrderHistory() = runBlocking { + fun testGetOrderHistory() = runBlockingTest { httpClient.giveJsonResponse("http://example.net/instances/testInstance/private/orders") { """{ "orders": [ { @@ -213,7 +216,7 @@ class MerchantApiTest { } @Test - fun testGiveRefund() = runBlocking { + fun testGiveRefund() = runBlockingTest { httpClient.giveJsonResponse("http://example.net/instances/testInstance/private/orders/$orderId/refund") { """{ "taler_refund_uri": "taler://refund/foo/bar" @@ -227,5 +230,4 @@ class MerchantApiTest { assertEquals("taler://refund/foo/bar", it.talerRefundUri) } } - } |