Skip to content

Commit

Permalink
BasePurchasesTests: changed default back to SK1
Browse files Browse the repository at this point in the history
Follow up to #1922. Most of the tests from the subclasses assume SK2 is disabled. This changes the default for those back to SK1.
The tests that do require SK2, define so explicitly.
  • Loading branch information
NachoSoto committed Sep 23, 2022
1 parent adf6353 commit 06ba49f
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 46 deletions.
12 changes: 10 additions & 2 deletions Tests/UnitTests/Purchasing/Purchases/BasePurchasesTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class BasePurchasesTests: TestCase {
try super.setUpWithError()

self.userDefaults = UserDefaults(suiteName: Self.userDefaultsSuiteName)
self.systemInfo = MockSystemInfo(finishTransactions: true)
self.systemInfo = MockSystemInfo(finishTransactions: true, storeKit2Setting: self.storeKit2Setting)
self.deviceCache = MockDeviceCache(sandboxEnvironmentDetector: self.systemInfo,
userDefaults: self.userDefaults)
self.requestFetcher = MockRequestFetcher()
Expand Down Expand Up @@ -146,7 +146,9 @@ class BasePurchasesTests: TestCase {
}

func setupPurchasesObserverModeOn() throws {
self.systemInfo = try MockSystemInfo(platformInfo: nil, finishTransactions: false)
self.systemInfo = try MockSystemInfo(platformInfo: nil,
finishTransactions: false,
storeKit2Setting: self.storeKit2Setting)
self.initializePurchasesInstance(appUserId: nil)
}

Expand Down Expand Up @@ -225,6 +227,12 @@ class BasePurchasesTests: TestCase {
self.storeKit1Wrapper.delegate?.storeKit1Wrapper(self.storeKit1Wrapper, updatedTransaction: transaction)
}

var storeKit2Setting: StoreKit2Setting {
// Even though the new default is StoreKit 2, most of the tests from this parent class
// we written for SK1. Therefore we want to default to it being disabled.
return .enabledOnlyForOptimizations
}

}

extension BasePurchasesTests {
Expand Down
Loading

0 comments on commit 06ba49f

Please sign in to comment.