@@ -34,17 +34,18 @@ class RoomLifecycleManagerTest {
34
34
)
35
35
36
36
@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 {
38
38
val statusLifecycle = spyk<DefaultRoomLifecycle >().apply {
39
39
setStatus(RoomStatus .Attached )
40
40
}
41
41
val roomLifecycle = spyk(RoomLifecycleManager (roomScope, statusLifecycle, createRoomFeatureMocks()))
42
42
val result = kotlin.runCatching { roomLifecycle.attach() }
43
43
Assert .assertTrue(result.isSuccess)
44
+ assertWaiter { roomLifecycle.atomicCoroutineScope().finishedProcessing }
44
45
}
45
46
46
47
@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 {
48
49
val statusLifecycle = spyk<DefaultRoomLifecycle >().apply {
49
50
setStatus(RoomStatus .Releasing )
50
51
}
@@ -55,12 +56,13 @@ class RoomLifecycleManagerTest {
55
56
}
56
57
}
57
58
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 }
60
62
}
61
63
62
64
@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 {
64
66
val statusLifecycle = spyk<DefaultRoomLifecycle >().apply {
65
67
setStatus(RoomStatus .Released )
66
68
}
@@ -71,8 +73,9 @@ class RoomLifecycleManagerTest {
71
73
}
72
74
}
73
75
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 }
76
79
}
77
80
78
81
@Test
@@ -115,8 +118,9 @@ class RoomLifecycleManagerTest {
115
118
val exception = result.exceptionOrNull() as AblyException
116
119
117
120
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 }
120
124
121
125
coVerify { roomLifecycle.release() }
122
126
}
@@ -130,6 +134,7 @@ class RoomLifecycleManagerTest {
130
134
}
131
135
val roomLifecycle = spyk(RoomLifecycleManager (roomScope, statusLifecycle, emptyList()))
132
136
roomLifecycle.attach()
137
+
133
138
Assert .assertEquals(RoomStatus .Attaching , roomStatusChanges[0 ].current)
134
139
Assert .assertEquals(RoomStatus .Attached , roomStatusChanges[1 ].current)
135
140
assertWaiter { roomLifecycle.atomicCoroutineScope().finishedProcessing }
@@ -190,7 +195,6 @@ class RoomLifecycleManagerTest {
190
195
}
191
196
justRun { roomLifecycle invokeNoArgs " clearAllTransientDetachTimeouts" }
192
197
193
- roomLifecycle.attach()
194
198
val result = kotlin.runCatching { roomLifecycle.attach() }
195
199
196
200
// CHA-RL1g1
0 commit comments