-
Notifications
You must be signed in to change notification settings - Fork 243
/
Copy pathRequest5ConcurrentKtTest.kt
31 lines (29 loc) · 1.34 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
31
package tasks
import contributors.MockGithubService
import contributors.expectedConcurrentResults
import contributors.testRequestData
import kotlinx.coroutines.runBlocking
import org.junit.Assert
import org.junit.Test
class Request5ConcurrentKtTest {
@Test
fun testConcurrent() = runBlocking {
val startTime = System.currentTimeMillis()
val result = loadContributorsConcurrent(MockGithubService, testRequestData)
Assert.assertEquals("Wrong result for 'loadContributorsConcurrent'", expectedConcurrentResults.users, result)
val totalTime = System.currentTimeMillis() - startTime
/*
// TODO: uncomment this assertion
Assert.assertEquals(
"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)",
expectedConcurrentResults.timeFromStart, totalTime
)
*/
Assert.assertTrue(
"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)",
totalTime in expectedConcurrentResults.timeFromStart..(expectedConcurrentResults.timeFromStart + 500)
)
}
}