Skip to content

Commit

Permalink
Fix tests failing due to executor shutdown changes in PN 10.4.1 (#177)
Browse files Browse the repository at this point in the history
  • Loading branch information
wkal-pubnub authored Mar 3, 2025
1 parent c8a86b0 commit 427df06
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 30 deletions.
2 changes: 1 addition & 1 deletion gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ ktlint = "12.1.0"
dokka = "1.9.20"
kotlinx_serialization = "1.7.3"
kotlinx_coroutines = "1.9.0"
pubnub = "10.4.1"
pubnub = "10.4.3"
pubnub_swift = "8.3.1"

[libraries]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,11 @@ import com.pubnub.internal.PLATFORM
import com.pubnub.test.BaseIntegrationTest
import com.pubnub.test.await
import com.pubnub.test.randomString
import kotlinx.coroutines.CoroutineExceptionHandler
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.delay
import kotlinx.coroutines.launch
import kotlinx.coroutines.supervisorScope
import kotlinx.coroutines.test.runTest
import kotlinx.coroutines.withContext
import kotlin.test.AfterTest
Expand Down Expand Up @@ -131,38 +133,44 @@ abstract class BaseChatIntegrationTest : BaseIntegrationTest() {
val userPamClient: User by lazy(LazyThreadSafetyMode.NONE) { chatPamClient.currentUser }

@AfterTest
fun afterTest() = runTest {
try {
usersToRemove.forEach {
launch {
pubnub.removeUUIDMetadata(it).await()
}
}
if (PLATFORM != "iOS") {
usersToRemovePam.forEach {
launch {
pubnubPamServer.removeUUIDMetadata(it).await()
override fun after() {
runTest {
val exceptionHandler = CoroutineExceptionHandler { _, _ -> }
try {
supervisorScope {
usersToRemove.forEach {
launch(exceptionHandler) {
pubnub.removeUUIDMetadata(it).await()
}
}
}
}
channelsToRemove.forEach {
launch {
pubnub.removeChannelMetadata(it).await()
}
}
if (PLATFORM != "iOS") {
channelsToRemovePam.forEach {
launch {
pubnubPamServer.removeChannelMetadata(it).await()
if (PLATFORM != "iOS") {
usersToRemovePam.forEach {
launch(exceptionHandler) {
pubnubPamServer.removeUUIDMetadata(it).await()
}
}
}
channelsToRemove.forEach {
launch(exceptionHandler) {
pubnub.removeChannelMetadata(it).await()
}
}
if (PLATFORM != "iOS") {
channelsToRemovePam.forEach {
launch(exceptionHandler) {
pubnubPamServer.removeChannelMetadata(it).await()
}
}
}
}
} finally {
chat.destroy()
chat02.destroy()
chatPamClient.destroy()
chatPamServer.destroy()
}
} finally {
chat.destroy()
chat02.destroy()
chatPamClient.destroy()
chatPamServer.destroy()
}
super.after()
}

internal suspend fun delayInMillis(timeMillis: Long) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -293,8 +293,6 @@ class PubNubTest(

fun close() {
pubNub.unsubscribeAll()
pubNub.destroy()

val remainingMessages = buildList {
messageQueue.tryReceive().getOrNull()?.apply { add(this) } ?: return@buildList
}
Expand Down

0 comments on commit 427df06

Please sign in to comment.