This repository was archived by the owner on Feb 22, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 9.7k
[in_app_purchase] Implements transaction caching for StoreKit #4985
Merged
Merged
Changes from 3 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
2bf962e
Merge remote-tracking branch 'upstream/main'
mvanbeusekom 7c834f6
Implement transaction caching for store kit
mvanbeusekom f712114
Merge remote-tracking branch 'upstream/main' into issue/94011
mvanbeusekom 1790118
Merge remote-tracking branch 'upstream/main' into issue/94011
mvanbeusekom eedda91
Processed feedback on pull request.
mvanbeusekom cfddf71
Applied additional feedback on pull request
mvanbeusekom 45f0597
Fix formatting
mvanbeusekom File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
4 changes: 4 additions & 0 deletions
4
packages/in_app_purchase/in_app_purchase_storekit/CHANGELOG.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...app_purchase_storekit/example/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
56 changes: 56 additions & 0 deletions
56
..._app_purchase/in_app_purchase_storekit/example/ios/RunnerTests/FIATransactionCacheTests.m
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,56 @@ | ||
| // Copyright 2013 The Flutter Authors. All rights reserved. | ||
| // Use of this source code is governed by a BSD-style license that can be | ||
| // found in the LICENSE file. | ||
|
|
||
| #import <XCTest/XCTest.h> | ||
|
|
||
| @import in_app_purchase_storekit; | ||
|
|
||
| @interface FIATransactionCacheTests : XCTestCase | ||
|
|
||
| @end | ||
|
|
||
| @implementation FIATransactionCacheTests | ||
|
|
||
| - (void)testAddObjectsForNewKey { | ||
| NSArray *dummyArray = @[ @1, @2, @3 ]; | ||
| FIATransactionCache *cache = [[FIATransactionCache alloc] init]; | ||
| [cache addObjects:dummyArray forKey:TransactionCacheKeyUpdatedTransactions]; | ||
|
|
||
| XCTAssertEqual(dummyArray, [cache getObjectsForKey:TransactionCacheKeyUpdatedTransactions]); | ||
| } | ||
|
|
||
| - (void)testAddObjectsForExistingKey { | ||
| NSArray *dummyArray = @[ @1, @2, @3 ]; | ||
| FIATransactionCache *cache = [[FIATransactionCache alloc] init]; | ||
| [cache addObjects:dummyArray forKey:TransactionCacheKeyUpdatedTransactions]; | ||
|
|
||
| XCTAssertEqual(dummyArray, [cache getObjectsForKey:TransactionCacheKeyUpdatedTransactions]); | ||
|
|
||
| [cache addObjects:@[ @4, @5, @6 ] forKey:TransactionCacheKeyUpdatedTransactions]; | ||
|
|
||
| NSArray *expected = @[ @1, @2, @3, @4, @5, @6 ]; | ||
| XCTAssertEqualObjects(expected, [cache getObjectsForKey:TransactionCacheKeyUpdatedTransactions]); | ||
| } | ||
|
|
||
| - (void)testGetObjectsForNonExistingKey { | ||
| FIATransactionCache *cache = [[FIATransactionCache alloc] init]; | ||
| XCTAssertNil([cache getObjectsForKey:TransactionCacheKeyUpdatedTransactions]); | ||
| } | ||
|
|
||
| - (void)testRemoveObjectsForNonExistingKey { | ||
| FIATransactionCache *cache = [[FIATransactionCache alloc] init]; | ||
| [cache removeObjectsForKey:TransactionCacheKeyUpdatedTransactions]; | ||
| } | ||
|
|
||
| - (void)testRemoveObjectsForExistingKey { | ||
| NSArray *dummyArray = @[ @1, @2, @3 ]; | ||
| FIATransactionCache *cache = [[FIATransactionCache alloc] init]; | ||
| [cache addObjects:dummyArray forKey:TransactionCacheKeyUpdatedTransactions]; | ||
|
|
||
| XCTAssertEqual(dummyArray, [cache getObjectsForKey:TransactionCacheKeyUpdatedTransactions]); | ||
|
|
||
| [cache removeObjectsForKey:TransactionCacheKeyUpdatedTransactions]; | ||
| XCTAssertNil([cache getObjectsForKey:TransactionCacheKeyUpdatedTransactions]); | ||
| } | ||
| @end | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just to be safe, it would be good to add something for each key before, and assert that they are all nil after.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You are right, should have done so right away.