From 5f33ec9b4132a1a8e7f5fea30a3c3d67774bb2ba Mon Sep 17 00:00:00 2001 From: Kamo Spertsyan Date: Mon, 25 Dec 2023 22:04:20 +0300 Subject: [PATCH 1/4] Purchase test fix --- .../sdk/internal/QonversionRepositoryIntegrationTest.kt | 2 +- .../android/sdk/internal/repository/DefaultRepository.kt | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/sdk/src/androidTest/java/com/qonversion/android/sdk/internal/QonversionRepositoryIntegrationTest.kt b/sdk/src/androidTest/java/com/qonversion/android/sdk/internal/QonversionRepositoryIntegrationTest.kt index da343f73..bf9287f1 100644 --- a/sdk/src/androidTest/java/com/qonversion/android/sdk/internal/QonversionRepositoryIntegrationTest.kt +++ b/sdk/src/androidTest/java/com/qonversion/android/sdk/internal/QonversionRepositoryIntegrationTest.kt @@ -237,7 +237,7 @@ internal class QonversionRepositoryIntegrationTest { } @Test - fun purchase_for_existing_user() { + fun purchaseForExistingUser() { // given val signal = CountDownLatch(1) diff --git a/sdk/src/main/java/com/qonversion/android/sdk/internal/repository/DefaultRepository.kt b/sdk/src/main/java/com/qonversion/android/sdk/internal/repository/DefaultRepository.kt index a7316c25..9d596a80 100644 --- a/sdk/src/main/java/com/qonversion/android/sdk/internal/repository/DefaultRepository.kt +++ b/sdk/src/main/java/com/qonversion/android/sdk/internal/repository/DefaultRepository.kt @@ -40,6 +40,7 @@ import com.qonversion.android.sdk.internal.dto.request.ViewsRequest import com.qonversion.android.sdk.internal.dto.request.data.InitRequestData import com.qonversion.android.sdk.internal.dto.request.data.UserPropertyRequestData import com.qonversion.android.sdk.internal.enqueue +import com.qonversion.android.sdk.internal.isInternalServerError import com.qonversion.android.sdk.internal.purchase.Purchase import com.qonversion.android.sdk.internal.purchase.PurchaseHistory import com.qonversion.android.sdk.internal.logger.Logger @@ -468,7 +469,7 @@ internal class DefaultRepository internal constructor( api.purchase(purchaseRequest).enqueue { onResponse = { - logger.release("purchaseRequest - ${it.getLogMessage()}") +// logger.release("purchaseRequest - ${it.getLogMessage()}") val body = it.body() if (body != null && body.success) { callback.onSuccess(body.data) @@ -520,7 +521,7 @@ internal class DefaultRepository internal constructor( retry: (attemptIndex: Int) -> Unit ) { // Retrying only errors caused by client network connection problems (errorCode == null) or server side problems - if (attemptIndex < MAX_RETRIES_COUNT) { + if (attemptIndex < MAX_RETRIES_COUNT && (errorCode == null || errorCode.isInternalServerError())) { val nextAttemptIndex = attemptIndex + 1 // For the first error retry instantly. if (attemptIndex == 0) { From f89b3b0e1c88ef2b5b261e3a1c4b4ddf90ade818 Mon Sep 17 00:00:00 2001 From: Kamo Spertsyan Date: Wed, 27 Dec 2023 10:57:58 +0300 Subject: [PATCH 2/4] Attempt to see the test results --- .github/workflows/integration_tests.yml | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/.github/workflows/integration_tests.yml b/.github/workflows/integration_tests.yml index 8d4e2d73..42bc0b27 100644 --- a/.github/workflows/integration_tests.yml +++ b/.github/workflows/integration_tests.yml @@ -25,4 +25,10 @@ jobs: uses: reactivecircus/android-emulator-runner@v2 with: api-level: 28 - script: ./gradlew sdk:connectedAndroidTest \ No newline at end of file + script: ./gradlew sdk:connectedAndroidTest + + - name: Unit tests results + uses: actions/upload-artifact@v3 + with: + name: test-results + path: sdk/build/reports/androidTests/connected/index.html \ No newline at end of file From ca7eb73680cb8aa18646efe904470e399bbaacb8 Mon Sep 17 00:00:00 2001 From: Kamo Spertsyan Date: Wed, 27 Dec 2023 15:26:30 +0300 Subject: [PATCH 3/4] Attempt to see the test results --- .../android/sdk/internal/repository/DefaultRepository.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sdk/src/main/java/com/qonversion/android/sdk/internal/repository/DefaultRepository.kt b/sdk/src/main/java/com/qonversion/android/sdk/internal/repository/DefaultRepository.kt index 9d596a80..14d9846a 100644 --- a/sdk/src/main/java/com/qonversion/android/sdk/internal/repository/DefaultRepository.kt +++ b/sdk/src/main/java/com/qonversion/android/sdk/internal/repository/DefaultRepository.kt @@ -469,7 +469,7 @@ internal class DefaultRepository internal constructor( api.purchase(purchaseRequest).enqueue { onResponse = { -// logger.release("purchaseRequest - ${it.getLogMessage()}") + logger.release("purchaseRequest - ${it.getLogMessage()}") val body = it.body() if (body != null && body.success) { callback.onSuccess(body.data) From 534464cc0560d3dcfaabaf4f7611a86b97d6065f Mon Sep 17 00:00:00 2001 From: Kamo Spertsyan Date: Thu, 28 Dec 2023 11:25:27 +0300 Subject: [PATCH 4/4] Make the artifact uploading step to execute even on fail. --- .github/workflows/integration_tests.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/integration_tests.yml b/.github/workflows/integration_tests.yml index 42bc0b27..65db8a5a 100644 --- a/.github/workflows/integration_tests.yml +++ b/.github/workflows/integration_tests.yml @@ -28,6 +28,7 @@ jobs: script: ./gradlew sdk:connectedAndroidTest - name: Unit tests results + if: always() uses: actions/upload-artifact@v3 with: name: test-results