Skip to content

Commit ed090c6

Browse files
committed
Merge branch 'rename/room_and_connection_status' into feature/roomlifecycle-detach-with-retry
2 parents a0978f1 + aeb2ba3 commit ed090c6

File tree

1 file changed

+14
-10
lines changed

1 file changed

+14
-10
lines changed

chat-android/src/test/java/com/ably/chat/RoomLifecycleManagerTest.kt

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -34,17 +34,18 @@ class RoomLifecycleManagerTest {
3434
)
3535

3636
@Test
37-
fun `(CHA-RL1a) Attach success when channel in already in attached state`() = runTest {
37+
fun `(CHA-RL1a) Attach success when room is already in attached state`() = runTest {
3838
val statusLifecycle = spyk<DefaultRoomLifecycle>().apply {
3939
setStatus(RoomStatus.Attached)
4040
}
4141
val roomLifecycle = spyk(RoomLifecycleManager(roomScope, statusLifecycle, createRoomFeatureMocks()))
4242
val result = kotlin.runCatching { roomLifecycle.attach() }
4343
Assert.assertTrue(result.isSuccess)
44+
assertWaiter { roomLifecycle.atomicCoroutineScope().finishedProcessing }
4445
}
4546

4647
@Test
47-
fun `(CHA-RL1b) Attach throws exception when channel in releasing state`() = runTest {
48+
fun `(CHA-RL1b) Attach throws exception when room in releasing state`() = runTest {
4849
val statusLifecycle = spyk<DefaultRoomLifecycle>().apply {
4950
setStatus(RoomStatus.Releasing)
5051
}
@@ -55,12 +56,13 @@ class RoomLifecycleManagerTest {
5556
}
5657
}
5758
Assert.assertEquals("unable to attach room; room is releasing", exception.errorInfo.message)
58-
Assert.assertEquals(102_102, exception.errorInfo.code)
59-
Assert.assertEquals(500, exception.errorInfo.statusCode)
59+
Assert.assertEquals(ErrorCodes.RoomIsReleasing.errorCode, exception.errorInfo.code)
60+
Assert.assertEquals(HttpStatusCodes.InternalServerError, exception.errorInfo.statusCode)
61+
assertWaiter { roomLifecycle.atomicCoroutineScope().finishedProcessing }
6062
}
6163

6264
@Test
63-
fun `(CHA-RL1c) Attach throws exception when channel in released state`() = runTest {
65+
fun `(CHA-RL1c) Attach throws exception when room in released state`() = runTest {
6466
val statusLifecycle = spyk<DefaultRoomLifecycle>().apply {
6567
setStatus(RoomStatus.Released)
6668
}
@@ -71,8 +73,9 @@ class RoomLifecycleManagerTest {
7173
}
7274
}
7375
Assert.assertEquals("unable to attach room; room is released", exception.errorInfo.message)
74-
Assert.assertEquals(102_103, exception.errorInfo.code)
75-
Assert.assertEquals(500, exception.errorInfo.statusCode)
76+
Assert.assertEquals(ErrorCodes.RoomIsReleased.errorCode, exception.errorInfo.code)
77+
Assert.assertEquals(HttpStatusCodes.InternalServerError, exception.errorInfo.statusCode)
78+
assertWaiter { roomLifecycle.atomicCoroutineScope().finishedProcessing }
7679
}
7780

7881
@Test
@@ -115,8 +118,9 @@ class RoomLifecycleManagerTest {
115118
val exception = result.exceptionOrNull() as AblyException
116119

117120
Assert.assertEquals("unable to attach room; room is released", exception.errorInfo.message)
118-
Assert.assertEquals(102_103, exception.errorInfo.code)
119-
Assert.assertEquals(500, exception.errorInfo.statusCode)
121+
Assert.assertEquals(ErrorCodes.RoomIsReleased.errorCode, exception.errorInfo.code)
122+
Assert.assertEquals(HttpStatusCodes.InternalServerError, exception.errorInfo.statusCode)
123+
assertWaiter { roomLifecycle.atomicCoroutineScope().finishedProcessing }
120124

121125
coVerify { roomLifecycle.release() }
122126
}
@@ -130,6 +134,7 @@ class RoomLifecycleManagerTest {
130134
}
131135
val roomLifecycle = spyk(RoomLifecycleManager(roomScope, statusLifecycle, emptyList()))
132136
roomLifecycle.attach()
137+
133138
Assert.assertEquals(RoomStatus.Attaching, roomStatusChanges[0].current)
134139
Assert.assertEquals(RoomStatus.Attached, roomStatusChanges[1].current)
135140
assertWaiter { roomLifecycle.atomicCoroutineScope().finishedProcessing }
@@ -190,7 +195,6 @@ class RoomLifecycleManagerTest {
190195
}
191196
justRun { roomLifecycle invokeNoArgs "clearAllTransientDetachTimeouts" }
192197

193-
roomLifecycle.attach()
194198
val result = kotlin.runCatching { roomLifecycle.attach() }
195199

196200
// CHA-RL1g1

0 commit comments

Comments
 (0)