Skip to content

Commit 34ed43e

Browse files
committed
Update test with backend error 400
1 parent 276b1a8 commit 34ed43e

1 file changed

Lines changed: 28 additions & 1 deletion

File tree

OneSignalSDK/onesignal/core/src/test/java/com/onesignal/user/internal/operations/LoginUserOperationExecutorTests.kt

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ class LoginUserOperationExecutorTests : FunSpec({
136136
coVerify(exactly = 1) { mockUserBackendService.createUser(appId, mapOf(), any(), any()) }
137137
}
138138

139-
test("login anonymous user fails with no retry when backend error condition exists") {
139+
test("login anonymous user fails with no retry when hit with backend error 404") {
140140
// Given
141141
val mockUserBackendService = mockk<IUserBackendService>()
142142
coEvery { mockUserBackendService.createUser(any(), any(), any(), any()) } throws BackendException(404, "NOT FOUND")
@@ -158,6 +158,33 @@ class LoginUserOperationExecutorTests : FunSpec({
158158
// When
159159
val response = loginUserOperationExecutor.execute(operations)
160160

161+
// Then
162+
response.result shouldBe ExecutionResult.FAIL_PAUSE_OPREPO
163+
coVerify(exactly = 1) { mockUserBackendService.createUser(appId, mapOf(), any(), any()) }
164+
}
165+
166+
test("login anonymous user fails with no retry when hit with backend error 400") {
167+
// Given
168+
val mockUserBackendService = mockk<IUserBackendService>()
169+
coEvery { mockUserBackendService.createUser(any(), any(), any(), any()) } throws BackendException(400, "INVALID")
170+
171+
val mockIdentityOperationExecutor = mockk<IdentityOperationExecutor>()
172+
173+
val mockIdentityModelStore = MockHelper.identityModelStore()
174+
val mockPropertiesModelStore = MockHelper.propertiesModelStore()
175+
val mockSubscriptionsModelStore = mockk<SubscriptionModelStore>()
176+
177+
val loginUserOperationExecutor =
178+
LoginUserOperationExecutor(mockIdentityOperationExecutor, AndroidMockHelper.applicationService(), MockHelper.deviceService(), mockUserBackendService, mockIdentityModelStore, mockPropertiesModelStore, mockSubscriptionsModelStore, MockHelper.configModelStore(), MockHelper.languageContext())
179+
val operations =
180+
listOf<Operation>(
181+
LoginUserOperation(appId, localOneSignalId, null, null),
182+
createSubscriptionOperation,
183+
)
184+
185+
// When
186+
val response = loginUserOperationExecutor.execute(operations)
187+
161188
// Then
162189
response.result shouldBe ExecutionResult.FAIL_NORETRY
163190
coVerify(exactly = 1) { mockUserBackendService.createUser(appId, mapOf(), any(), any()) }

0 commit comments

Comments
 (0)