Skip to content

Commit 25c43f4

Browse files
committed
Fix tests running forever
1 parent 96a102e commit 25c43f4

File tree

1 file changed

+16
-10
lines changed

1 file changed

+16
-10
lines changed

lib/src/androidTest/java/at/bitfire/cert4android/UserDecisionRegistryTest.kt

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -63,13 +63,16 @@ class UserDecisionRegistryTest {
6363
}
6464
}
6565
val results = Collections.synchronizedList(mutableListOf<Boolean>())
66-
runBlocking {
67-
repeat(5) {
68-
launch(Dispatchers.Default) {
69-
results += registry.check(testCert, this, getUserDecision)
66+
runBlocking(Dispatchers.Default) {
67+
try {
68+
repeat(5) {
69+
launch {
70+
results += registry.check(testCert, this, getUserDecision)
71+
}
7072
}
73+
} finally {
74+
canSendFeedback.release()
7175
}
72-
canSendFeedback.release()
7376
}
7477
synchronized(registry.pendingDecisions) {
7578
assertFalse(registry.pendingDecisions.containsKey(testCert))
@@ -89,13 +92,16 @@ class UserDecisionRegistryTest {
8992
}
9093
}
9194
val results = Collections.synchronizedList(mutableListOf<Boolean>())
92-
runBlocking {
93-
repeat(5) {
94-
launch(Dispatchers.Default) {
95-
results += registry.check(testCert, this, getUserDecision)
95+
runBlocking(Dispatchers.Default) {
96+
try {
97+
repeat(5) {
98+
launch {
99+
results += registry.check(testCert, this, getUserDecision)
100+
}
96101
}
102+
} finally {
103+
canSendFeedback.release()
97104
}
98-
canSendFeedback.release()
99105
}
100106
synchronized(registry.pendingDecisions) {
101107
assertFalse(registry.pendingDecisions.containsKey(testCert))

0 commit comments

Comments
 (0)