Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 20 additions & 2 deletions src/commonTest/kotlin/co/pokeapi/pokekotlin/test/BulkTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,15 @@ package co.pokeapi.pokekotlin.test

import co.pokeapi.pokekotlin.model.ResourceSummary
import co.pokeapi.pokekotlin.model.ResourceSummaryList
import kotlin.math.min
import kotlin.test.Test
import kotlin.test.fail
import kotlinx.coroutines.test.runTest

@IgnoreOnJvm // Should work on JVM but it's OOMing.
private const val FIRST_N = 100
private const val LAST_N = 100
private const val MIDDLE_N = 100

class BulkTest {

private suspend fun testCase(cat: String, id: Int, getObject: suspend (Int) -> Any) {
Expand All @@ -24,7 +28,21 @@ class BulkTest {
getObject: suspend (Int) -> O,
) {
val list = getList(0, getList(0, 0).count).results
list.forEach { testCase(list[0].category, it.id, getObject) }
val category = list[0].category

list.take(FIRST_N).forEach { testCase(category, it.id, getObject) }

if (list.size > FIRST_N + LAST_N) {
val n = min(MIDDLE_N, list.size - FIRST_N - LAST_N)
list.drop(FIRST_N).dropLast(LAST_N).shuffled().take(n).forEach {
testCase(category, it.id, getObject)
}
}

if (list.size > FIRST_N) {
val n = min(LAST_N, list.size - FIRST_N)
list.takeLast(n).forEach { testCase(category, it.id, getObject) }
}
}

@Test
Expand Down
6 changes: 0 additions & 6 deletions src/commonTest/kotlin/co/pokeapi/pokekotlin/test/Ignore.kt

This file was deleted.

3 changes: 0 additions & 3 deletions src/jsTest/kotlin/co/pokeapi/pokekotlin/test/Ignore.js.kt

This file was deleted.

3 changes: 0 additions & 3 deletions src/jvmTest/kotlin/co/pokeapi/pokekotlin/test/Ignore.jvm.kt

This file was deleted.

This file was deleted.

This file was deleted.

Loading