Skip to content

Commit

Permalink
Merge branch 'tests/room-lifecycle-manager-retry' into feature/rooms-…
Browse files Browse the repository at this point in the history
…async-get
  • Loading branch information
sacOO7 committed Nov 22, 2024
2 parents ae31f2b + 14d8090 commit c1a4504
Showing 1 changed file with 14 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -49,17 +49,18 @@ class AttachTest {
)

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

@Test
fun `(CHA-RL1b) Attach throws exception when channel in releasing state`() = runTest {
fun `(CHA-RL1b) Attach throws exception when room in releasing state`() = runTest {
val statusLifecycle = spyk<DefaultRoomLifecycle>().apply {
setStatus(RoomStatus.Releasing)
}
Expand All @@ -70,12 +71,13 @@ class AttachTest {
}
}
Assert.assertEquals("unable to attach room; room is releasing", exception.errorInfo.message)
Assert.assertEquals(102_102, exception.errorInfo.code)
Assert.assertEquals(500, exception.errorInfo.statusCode)
Assert.assertEquals(ErrorCodes.RoomIsReleasing.errorCode, exception.errorInfo.code)
Assert.assertEquals(HttpStatusCodes.InternalServerError, exception.errorInfo.statusCode)
assertWaiter { roomLifecycle.atomicCoroutineScope().finishedProcessing }
}

@Test
fun `(CHA-RL1c) Attach throws exception when channel in released state`() = runTest {
fun `(CHA-RL1c) Attach throws exception when room in released state`() = runTest {
val statusLifecycle = spyk<DefaultRoomLifecycle>().apply {
setStatus(RoomStatus.Released)
}
Expand All @@ -86,8 +88,9 @@ class AttachTest {
}
}
Assert.assertEquals("unable to attach room; room is released", exception.errorInfo.message)
Assert.assertEquals(102_103, exception.errorInfo.code)
Assert.assertEquals(500, exception.errorInfo.statusCode)
Assert.assertEquals(ErrorCodes.RoomIsReleased.errorCode, exception.errorInfo.code)
Assert.assertEquals(HttpStatusCodes.InternalServerError, exception.errorInfo.statusCode)
assertWaiter { roomLifecycle.atomicCoroutineScope().finishedProcessing }
}

@Test
Expand Down Expand Up @@ -130,8 +133,9 @@ class AttachTest {
val exception = result.exceptionOrNull() as AblyException

Assert.assertEquals("unable to attach room; room is released", exception.errorInfo.message)
Assert.assertEquals(102_103, exception.errorInfo.code)
Assert.assertEquals(500, exception.errorInfo.statusCode)
Assert.assertEquals(ErrorCodes.RoomIsReleased.errorCode, exception.errorInfo.code)
Assert.assertEquals(HttpStatusCodes.InternalServerError, exception.errorInfo.statusCode)
assertWaiter { roomLifecycle.atomicCoroutineScope().finishedProcessing }

coVerify { roomLifecycle.release() }
}
Expand All @@ -145,6 +149,7 @@ class AttachTest {
}
val roomLifecycle = spyk(RoomLifecycleManager(roomScope, statusLifecycle, emptyList()))
roomLifecycle.attach()

Assert.assertEquals(RoomStatus.Attaching, roomStatusChanges[0].current)
Assert.assertEquals(RoomStatus.Attached, roomStatusChanges[1].current)
assertWaiter { roomLifecycle.atomicCoroutineScope().finishedProcessing }
Expand Down Expand Up @@ -205,7 +210,6 @@ class AttachTest {
}
justRun { roomLifecycle invokeNoArgs "clearAllTransientDetachTimeouts" }

roomLifecycle.attach()
val result = kotlin.runCatching { roomLifecycle.attach() }

// CHA-RL1g1
Expand Down

0 comments on commit c1a4504

Please sign in to comment.