Skip to content

Commit

Permalink
Update checkout action (#287)
Browse files Browse the repository at this point in the history
* Update checkout action

* Make testObjectRemove less flakey

* Make testObjectRemoveAll less flakey
  • Loading branch information
garrettmoon authored Oct 6, 2020
1 parent 4c3389b commit 5d58748
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 15 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,14 @@ jobs:
matrix:
platform: ['iOS Simulator,name=iPhone 8']
steps:
- uses: actions/checkout@v1
- uses: actions/checkout@v2
- name: Test
run: make test
analyze:
name: Analyze
runs-on: macOS-latest
steps:
- uses: actions/checkout@v1
- uses: actions/checkout@v2
- name: analyze
run: make analyze
cocoapods:
Expand Down
22 changes: 9 additions & 13 deletions Tests/PINCacheTests.m
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ @interface PINDiskCache()

@property (assign, nonatomic) BOOL diskStateKnown;
@property (strong, nonatomic) NSDictionary *metadata;
@property (readonly) PINOperationQueue *operationQueue;

+ (dispatch_queue_t)sharedTrashQueue;
+ (NSURL *)sharedTrashURL;
Expand Down Expand Up @@ -272,7 +273,6 @@ - (void)testObjectGetWithInvalidKey
- (void)testObjectRemove
{
NSString *key = @"key";
dispatch_semaphore_t semaphore = dispatch_semaphore_create(0);

self.cache[key] = [self image];

Expand All @@ -285,13 +285,12 @@ - (void)testObjectRemove
self.cache.diskCache.didRemoveObjectBlock = ^(PINDiskCache * _Nonnull cache, NSString * _Nonnull key, id<NSCoding> _Nullable object) {
didRemoveObjectBlockCalled = YES;
};

[self.cache removeObjectForKeyAsync:key completion:^(id<PINCaching> cache, NSString *key, id object) {
dispatch_semaphore_signal(semaphore);
}];

dispatch_semaphore_wait(semaphore, [self timeout]);

// Clear out operation queue to ensure blocks are set.
[self.cache.diskCache.operationQueue waitUntilAllOperationsAreFinished];

[self.cache removeObjectForKey:key];

id object = self.cache[key];

XCTAssertNil(object, @"object was not removed");
Expand All @@ -303,7 +302,6 @@ - (void)testObjectRemoveAll
{
NSString *key1 = @"key1";
NSString *key2 = @"key2";
dispatch_semaphore_t semaphore = dispatch_semaphore_create(0);

self.cache[key1] = key1;
self.cache[key2] = key2;
Expand All @@ -317,12 +315,10 @@ - (void)testObjectRemoveAll
self.cache.diskCache.didRemoveAllObjectsBlock = ^(id<PINCaching> _Nonnull cache) {
didRemoveAllObjectsBlockCalled = YES;
};

[self.cache removeAllObjectsAsync:^(id<PINCaching> cache) {
dispatch_semaphore_signal(semaphore);
}];

dispatch_semaphore_wait(semaphore, [self timeout]);
[self.cache.diskCache.operationQueue waitUntilAllOperationsAreFinished];

[self.cache removeAllObjects];

id object1 = self.cache[key1];
id object2 = self.cache[key2];
Expand Down

0 comments on commit 5d58748

Please sign in to comment.