Skip to content

Commit

Permalink
OfferingsManager: don't clear offerings cache timestamp when reques…
Browse files Browse the repository at this point in the history
…t fails (#2359)

There is no reason to clear this and make the cache immediately stale.
Instead, failed requests would eventually make the cache stale after a
certain duration.
  • Loading branch information
NachoSoto authored Jun 14, 2023
1 parent 7cfbfe0 commit afc5b0f
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 22 deletions.
1 change: 0 additions & 1 deletion Sources/Purchasing/OfferingsManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,6 @@ private extension OfferingsManager {
) {
Logger.appleError(Strings.offering.fetching_offerings_error(error: error,
underlyingError: error.underlyingError))
self.deviceCache.clearOfferingsCacheTimestamp()
self.dispatchCompletionOnMainThreadIfPossible(completion, value: .failure(error))
}

Expand Down
21 changes: 0 additions & 21 deletions Tests/UnitTests/Purchasing/OfferingsManagerTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -336,27 +336,6 @@ extension OfferingsManagerTests {
}
}

func testFailBackendDeviceCacheClearsOfferingsCache() {
// given
self.mockOfferings.stubbedGetOfferingsCompletionResult = .failure(MockData.unexpectedBackendResponseError)
self.mockOfferingsFactory.emptyOfferings = true
self.mockSystemInfo.stubbedIsApplicationBackgrounded = false

let expectedCallCount = 1

// when
waitUntil { completed in
self.offeringsManager.offerings(appUserID: MockData.anyAppUserID) { _ in
completed()
}
}

// then
expect(self.mockOfferings.invokedGetOfferingsForAppUserIDCount) == expectedCallCount
expect(self.mockDeviceCache.clearOfferingsCacheTimestampCount) == expectedCallCount
expect(self.mockOfferings.invokedGetOfferingsForAppUserIDParameters?.randomDelay) == false
}

func testUpdateOfferingsCacheOK() throws {
// given
self.mockOfferings.stubbedGetOfferingsCompletionResult = .success(MockData.anyBackendOfferingsResponse)
Expand Down

0 comments on commit afc5b0f

Please sign in to comment.