Skip to content

Commit

Permalink
Fix test
Browse files Browse the repository at this point in the history
  • Loading branch information
wkal-pubnub committed Jan 10, 2025
1 parent 76f87de commit 96b294c
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,11 @@ import com.pubnub.chat.internal.mutelist.MutedUsersImpl
import com.pubnub.chat.mutelist.MutedUsers
import com.pubnub.test.await
import com.pubnub.test.test
import delayForHistory
import kotlinx.coroutines.test.runTest
import kotlin.test.Test
import kotlin.test.assertContains
import kotlin.test.assertFalse
import kotlin.test.assertTrue
import kotlin.time.Duration.Companion.seconds

class MutedUsersIntegrationTest : BaseChatIntegrationTest() {
private fun getMutedUsers(sync: Boolean = false): MutedUsers = MutedUsersImpl(pubnub, pubnub.configuration.userId.value, sync)
Expand Down Expand Up @@ -48,15 +46,14 @@ class MutedUsersIntegrationTest : BaseChatIntegrationTest() {
}

@Test
fun sync_updates_between_clients() = runTest(timeout = 10.seconds) {
fun sync_updates_between_clients() = runTest {
val mutedUsers1 = getMutedUsers(true)
val mutedUsers2 = MutedUsersImpl(pubnub02, pubnub.configuration.userId.value, true)
pubnub.test(backgroundScope) {
pubnub.awaitSubscribe(listOf("aaa")) // just to kick off connection
pubnub.awaitSubscribe(listOf("${PREFIX_PUBNUB_PRIVATE}${pubnub.configuration.userId.value}.mute1")) {
// custom subscription block empty, let mutedUsers subscribe for us
}
delayForHistory()
mutedUsers2.muteUser(someUser02.id).await()
nextEvent<PNEvent>()
assertContains(mutedUsers1.muteSet, someUser02.id)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,12 @@ class PubNubTest(
pubNub.removeListener(statusListener)
}
customSubscriptionBlock()
if (getSubscribedChannels().containsAll(channels) && getSubscribedChannelGroups().containsAll(
channelGroups
)
) {
cont.resume(Unit)
}
}

suspend fun PubNub.awaitUnsubscribe(
Expand Down

0 comments on commit 96b294c

Please sign in to comment.