File tree Expand file tree Collapse file tree 1 file changed +10
-4
lines changed
src/commonTest/kotlin/com.adamratzman/spotify Expand file tree Collapse file tree 1 file changed +10
-4
lines changed Original file line number Diff line number Diff line change @@ -42,17 +42,23 @@ suspend inline fun <reified T : Throwable> assertFailsWithSuspend(crossinline bl
4242 }
4343}
4444
45- fun <T > runTestOnDefaultDispatcher (block : suspend CoroutineScope .() -> T ): TestResult = runTest(timeout = 60 .seconds) {
45+ fun <T > runTestOnDefaultDispatcher (block : suspend CoroutineScope .() -> T ): TestResult = runTestOnDefaultDispatcher(block, shouldRetry = true )
46+
47+ fun <T > runTestOnDefaultDispatcher (block : suspend CoroutineScope .() -> T , shouldRetry : Boolean ): TestResult = runTest(timeout = 60 .seconds) {
4648 withContext(Dispatchers .Default ) {
4749 try {
4850 block()
4951 } catch (e: SpotifyException .BadRequestException ) {
5052 // we shouldn't fail just because we received a 5xx from spotify
51- if (e.statusCode ! in 500 .. 599 ) {
52- throw e;
53+ if (e.statusCode in 500 .. 599 ) {
54+ println ( " Received 5xx for block. " )
5355 }
5456
55- println (" Received 5xx for block." )
57+ if (shouldRetry) runTestOnDefaultDispatcher(block, shouldRetry = false )
58+ else throw e;
59+ } catch (e: Exception ) {
60+ if (shouldRetry) runTestOnDefaultDispatcher(block, shouldRetry = false )
61+ else throw e;
5662 }
5763 }
5864}
You can’t perform that action at this time.
0 commit comments