-
Notifications
You must be signed in to change notification settings - Fork 243
/
Copy pathRequest5ConcurrentKtTest.kt
30 lines (28 loc) · 1.36 KB
/
Request5ConcurrentKtTest.kt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
package tasks
import contributors.MockGithubService
import contributors.expectedConcurrentResults
import contributors.testRequestData
import kotlinx.coroutines.runBlocking
import org.junit.jupiter.api.Assertions
import org.junit.jupiter.api.Test
class Request5ConcurrentKtTest {
@Test
fun testConcurrent() = runBlocking {
val startTime = System.currentTimeMillis()
val result = loadContributorsConcurrent(MockGithubService, testRequestData)
Assertions.assertEquals(expectedConcurrentResults.users, result, "Wrong result for 'loadContributorsConcurrent'")
val totalTime = System.currentTimeMillis() - startTime
/*
// TODO: uncomment this assertion
Assertions.assertEquals(expectedConcurrentResults.timeFromStart, totalTime,
"The calls run concurrently, so the total virtual time should be 2200 ms: " +
"1000 ms for repos request plus max(1000, 1200, 800) = 1200 ms for concurrent contributors requests)"
)
*/
Assertions.assertTrue(
totalTime in expectedConcurrentResults.timeFromStart..(expectedConcurrentResults.timeFromStart + 500),
"The calls run concurrently, so the total virtual time should be 2200 ms: " +
"1000 ms for repos request plus max(1000, 1200, 800) = 1200 ms for concurrent contributors requests)"
)
}
}