Skip to content

Commit 900d76a

Browse files
committed
fixed subscription delete test when 404
If we get a 404 when we try to delete then it was already done at some point, so we count it as successful
1 parent 3faf8e2 commit 900d76a

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -539,7 +539,9 @@ class SubscriptionOperationExecutorTests : FunSpec({
539539
coVerify(exactly = 1) { mockSubscriptionBackendService.deleteSubscription(appId, remoteSubscriptionId) }
540540
}
541541

542-
test("delete subscription fails without retry when there is a backend error") {
542+
// If we get a 404 then the subscription has already been deleted,
543+
// so we count it as successful
544+
test("delete subscription is successful if there is a 404") {
543545
// Given
544546
val mockSubscriptionBackendService = mockk<ISubscriptionBackendService>()
545547
coEvery { mockSubscriptionBackendService.deleteSubscription(any(), any()) } throws BackendException(404)
@@ -566,7 +568,7 @@ class SubscriptionOperationExecutorTests : FunSpec({
566568
val response = subscriptionOperationExecutor.execute(operations)
567569

568570
// Then
569-
response.result shouldBe ExecutionResult.FAIL_NORETRY
571+
response.result shouldBe ExecutionResult.SUCCESS
570572
coVerify(exactly = 1) { mockSubscriptionBackendService.deleteSubscription(appId, remoteSubscriptionId) }
571573
}
572574
})

0 commit comments

Comments
 (0)