diff --git a/chat-android/src/test/java/com/ably/chat/room/AttachTest.kt b/chat-android/src/test/java/com/ably/chat/room/AttachTest.kt index ba98d817..1a3844a7 100644 --- a/chat-android/src/test/java/com/ably/chat/room/AttachTest.kt +++ b/chat-android/src/test/java/com/ably/chat/room/AttachTest.kt @@ -2,6 +2,7 @@ package com.ably.chat.room import com.ably.chat.DefaultRoomLifecycle import com.ably.chat.ErrorCodes +import com.ably.chat.HttpStatusCodes import com.ably.chat.ResolvedContributor import com.ably.chat.RoomLifecycleManager import com.ably.chat.RoomStatus @@ -47,17 +48,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().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().apply { setStatus(RoomStatus.Releasing) } @@ -68,12 +70,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().apply { setStatus(RoomStatus.Released) } @@ -84,8 +87,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 @@ -128,8 +132,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() } } @@ -143,6 +148,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 } @@ -203,7 +209,6 @@ class AttachTest { } justRun { roomLifecycle invokeNoArgs "clearAllTransientDetachTimeouts" } - roomLifecycle.attach() val result = kotlin.runCatching { roomLifecycle.attach() } // CHA-RL1g1