Skip to content

Commit

Permalink
Merge pull request #79 from apbendi/test-time
Browse files Browse the repository at this point in the history
Use a locally defined timeout for async integration test matchers
  • Loading branch information
apbendi committed Jul 26, 2016
2 parents 3899ac8 + a87f933 commit f673129
Show file tree
Hide file tree
Showing 7 changed files with 293 additions and 295 deletions.
148 changes: 74 additions & 74 deletions ios/iosTests/CMObjectIntegrationSpec.m

Large diffs are not rendered by default.

126 changes: 63 additions & 63 deletions ios/iosTests/CMStoreIntegrationSpec.m
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,9 @@
res = response;
}];

[[expectFutureValue(res) shouldEventually] beNonNil];
[[expectFutureValue(res.snippetResult.data) shouldEventually] beEmpty];
[[expectFutureValue(res.uploadStatuses) shouldEventually] haveCountOf:1];
[[expectFutureValue(res) shouldEventuallyBeforeTimingOutAfter(CM_TEST_TIMEOUT)] beNonNil];
[[expectFutureValue(res.snippetResult.data) shouldEventuallyBeforeTimingOutAfter(CM_TEST_TIMEOUT)] beEmpty];
[[expectFutureValue(res.uploadStatuses) shouldEventuallyBeforeTimingOutAfter(CM_TEST_TIMEOUT)] haveCountOf:1];
});

it(@"should allow the creation of another object and running a snippet", ^{
Expand All @@ -64,10 +64,10 @@
res = response;
}];

[[expectFutureValue(res) shouldEventually] beNonNil];
[[expectFutureValue(res.snippetResult) shouldEventually] beNonNil];
[[expectFutureValue(res.snippetResult.data[@"store"]) shouldEventually] equal:@"integration"];
[[expectFutureValue(res.uploadStatuses) shouldEventually] haveCountOf:1];
[[expectFutureValue(res) shouldEventuallyBeforeTimingOutAfter(CM_TEST_TIMEOUT)] beNonNil];
[[expectFutureValue(res.snippetResult) shouldEventuallyBeforeTimingOutAfter(CM_TEST_TIMEOUT)] beNonNil];
[[expectFutureValue(res.snippetResult.data[@"store"]) shouldEventuallyBeforeTimingOutAfter(CM_TEST_TIMEOUT)] equal:@"integration"];
[[expectFutureValue(res.uploadStatuses) shouldEventuallyBeforeTimingOutAfter(CM_TEST_TIMEOUT)] haveCountOf:1];
});

it(@"should be able to delete the venues", ^{
Expand All @@ -79,11 +79,11 @@
NSString *objectId1 = [venues[0] objectId];
NSString *objectId2 = [venues[0] objectId];

[[expectFutureValue(res) shouldEventually] beNonNil];
[[expectFutureValue(res.success) shouldEventually] haveCountOf:2];
[[expectFutureValue(res.success[objectId1]) shouldEventually] equal:@"deleted"];
[[expectFutureValue(res.success[objectId2]) shouldEventually] equal:@"deleted"];
[[expectFutureValue(res.objectErrors) shouldEventually] beEmpty];
[[expectFutureValue(res) shouldEventuallyBeforeTimingOutAfter(CM_TEST_TIMEOUT)] beNonNil];
[[expectFutureValue(res.success) shouldEventuallyBeforeTimingOutAfter(CM_TEST_TIMEOUT)] haveCountOf:2];
[[expectFutureValue(res.success[objectId1]) shouldEventuallyBeforeTimingOutAfter(CM_TEST_TIMEOUT)] equal:@"deleted"];
[[expectFutureValue(res.success[objectId2]) shouldEventuallyBeforeTimingOutAfter(CM_TEST_TIMEOUT)] equal:@"deleted"];
[[expectFutureValue(res.objectErrors) shouldEventuallyBeforeTimingOutAfter(CM_TEST_TIMEOUT)] beEmpty];
});

it(@"should be able to save all objects", ^{
Expand All @@ -107,10 +107,10 @@
NSString *objectId1 = [venues[0] objectId];
NSString *objectId2 = [venues[1] objectId];

[[expectFutureValue(res) shouldEventually] beNonNil];
[[expectFutureValue(res.uploadStatuses) shouldEventually] haveCountOf:2];
[[expectFutureValue(res.uploadStatuses[objectId1]) shouldEventually] equal:@"created"];
[[expectFutureValue(res.uploadStatuses[objectId2]) shouldEventually] equal:@"created"];
[[expectFutureValue(res) shouldEventuallyBeforeTimingOutAfter(CM_TEST_TIMEOUT)] beNonNil];
[[expectFutureValue(res.uploadStatuses) shouldEventuallyBeforeTimingOutAfter(CM_TEST_TIMEOUT)] haveCountOf:2];
[[expectFutureValue(res.uploadStatuses[objectId1]) shouldEventuallyBeforeTimingOutAfter(CM_TEST_TIMEOUT)] equal:@"created"];
[[expectFutureValue(res.uploadStatuses[objectId2]) shouldEventuallyBeforeTimingOutAfter(CM_TEST_TIMEOUT)] equal:@"created"];
});

it(@"should not throw an error if you try to save a nil object", ^{
Expand All @@ -136,9 +136,9 @@
res = response;
}];

[[expectFutureValue(res) shouldEventually] beNonNil];
[[expectFutureValue(res.key) shouldEventually] beNonNil];
[[expectFutureValue(theValue(res.result)) shouldEventually] equal:@(CMFileCreated)];
[[expectFutureValue(res) shouldEventuallyBeforeTimingOutAfter(CM_TEST_TIMEOUT)] beNonNil];
[[expectFutureValue(res.key) shouldEventuallyBeforeTimingOutAfter(CM_TEST_TIMEOUT)] beNonNil];
[[expectFutureValue(theValue(res.result)) shouldEventuallyBeforeTimingOutAfter(CM_TEST_TIMEOUT)] equal:@(CMFileCreated)];
});

__block NSString *nonUserKey = @"app_icon_something";
Expand All @@ -150,9 +150,9 @@
res = response;
}];

[[expectFutureValue(res) shouldEventually] beNonNil];
[[expectFutureValue(res.key) shouldEventually] equal:nonUserKey];
[[expectFutureValue(theValue(res.result)) shouldEventually] equal:@(CMFileCreated)];
[[expectFutureValue(res) shouldEventuallyBeforeTimingOutAfter(CM_TEST_TIMEOUT)] beNonNil];
[[expectFutureValue(res.key) shouldEventuallyBeforeTimingOutAfter(CM_TEST_TIMEOUT)] equal:nonUserKey];
[[expectFutureValue(theValue(res.result)) shouldEventuallyBeforeTimingOutAfter(CM_TEST_TIMEOUT)] equal:@(CMFileCreated)];
});

it(@"should fetch all the objects", ^{
Expand All @@ -163,8 +163,8 @@
[[ theValue([res.objects containsObject:venues[1]]) should] beTrue];
}];

[[expectFutureValue(res) shouldEventually] beNonNil];
[[expectFutureValue(res.objects) shouldEventually] haveCountOfAtLeast:2];
[[expectFutureValue(res) shouldEventuallyBeforeTimingOutAfter(CM_TEST_TIMEOUT)] beNonNil];
[[expectFutureValue(res.objects) shouldEventuallyBeforeTimingOutAfter(CM_TEST_TIMEOUT)] haveCountOfAtLeast:2];
});

it(@"should fetch the obejcts by key", ^{
Expand All @@ -179,8 +179,8 @@
[[res.objects should] contain:v1];
}];

[[expectFutureValue(res) shouldEventually] beNonNil];
[[expectFutureValue(res.objects) shouldEventually] haveCountOf:2];
[[expectFutureValue(res) shouldEventuallyBeforeTimingOutAfter(CM_TEST_TIMEOUT)] beNonNil];
[[expectFutureValue(res.objects) shouldEventuallyBeforeTimingOutAfter(CM_TEST_TIMEOUT)] haveCountOf:2];
});

it(@"should fetch all objects if the query is not specified", ^{
Expand All @@ -195,8 +195,8 @@
[[res.objects should] contain:v1];
}];

[[expectFutureValue(res) shouldEventually] beNonNil];
[[expectFutureValue(res.objects) shouldEventually] haveCountOfAtLeast:2];
[[expectFutureValue(res) shouldEventuallyBeforeTimingOutAfter(CM_TEST_TIMEOUT)] beNonNil];
[[expectFutureValue(res.objects) shouldEventuallyBeforeTimingOutAfter(CM_TEST_TIMEOUT)] haveCountOfAtLeast:2];
});

it(@"should delete an object", ^{
Expand All @@ -207,8 +207,8 @@
res = response;
}];

[[expectFutureValue(res) shouldEventually] beNonNil];
[[expectFutureValue(res.success) shouldEventually] haveCountOf:1];
[[expectFutureValue(res) shouldEventuallyBeforeTimingOutAfter(CM_TEST_TIMEOUT)] beNonNil];
[[expectFutureValue(res.success) shouldEventuallyBeforeTimingOutAfter(CM_TEST_TIMEOUT)] haveCountOf:1];
});

context(@"with a CMUser", ^{
Expand All @@ -220,7 +220,7 @@
code = resultCode;
[store setUser:user];
}];
[[expectFutureValue(theValue(code)) shouldEventually] equal:@(CMUserAccountLoginSucceeded)];
[[expectFutureValue(theValue(code)) shouldEventuallyBeforeTimingOutAfter(CM_TEST_TIMEOUT)] equal:@(CMUserAccountLoginSucceeded)];
});

it(@"should allow the user to add objects", ^{
Expand All @@ -231,9 +231,9 @@
}];
NSString *objectId1 = [venues[3] objectId];

[[expectFutureValue(res) shouldEventually] beNonNil];
[[expectFutureValue(res.uploadStatuses) shouldEventually] haveCountOf:1];
[[expectFutureValue(res.uploadStatuses[objectId1]) shouldEventually] equal:@"created"];
[[expectFutureValue(res) shouldEventuallyBeforeTimingOutAfter(CM_TEST_TIMEOUT)] beNonNil];
[[expectFutureValue(res.uploadStatuses) shouldEventuallyBeforeTimingOutAfter(CM_TEST_TIMEOUT)] haveCountOf:1];
[[expectFutureValue(res.uploadStatuses[objectId1]) shouldEventuallyBeforeTimingOutAfter(CM_TEST_TIMEOUT)] equal:@"created"];
});

it(@"should allow the user to get the object by class", ^{
Expand All @@ -245,8 +245,8 @@
[[fetched should] equal:venues[3]];
}];

[[expectFutureValue(res) shouldEventually] beNonNil];
[[expectFutureValue(res.objects) shouldEventually] haveCountOf:1];
[[expectFutureValue(res) shouldEventuallyBeforeTimingOutAfter(CM_TEST_TIMEOUT)] beNonNil];
[[expectFutureValue(res.objects) shouldEventuallyBeforeTimingOutAfter(CM_TEST_TIMEOUT)] haveCountOf:1];
});

it(@"should save all user objects with a save all", ^{
Expand All @@ -258,8 +258,8 @@
called++;
}];

[[expectFutureValue(res) shouldEventually] beNonNil];
[[expectFutureValue(theValue(called)) shouldEventually] equal:@3];
[[expectFutureValue(res) shouldEventuallyBeforeTimingOutAfter(CM_TEST_TIMEOUT)] beNonNil];
[[expectFutureValue(theValue(called)) shouldEventuallyBeforeTimingOutAfter(CM_TEST_TIMEOUT)] equal:@3];
});

it(@"should not throw an error when you attempt to save a nil user object", ^{
Expand All @@ -279,9 +279,9 @@
res = response;
}];

[[expectFutureValue(res) shouldEventually] beNonNil];
[[expectFutureValue(res.key) shouldEventually] beNonNil];
[[expectFutureValue(theValue(res.result)) shouldEventually] equal:@(CMFileCreated)];
[[expectFutureValue(res) shouldEventuallyBeforeTimingOutAfter(CM_TEST_TIMEOUT)] beNonNil];
[[expectFutureValue(res.key) shouldEventuallyBeforeTimingOutAfter(CM_TEST_TIMEOUT)] beNonNil];
[[expectFutureValue(theValue(res.result)) shouldEventuallyBeforeTimingOutAfter(CM_TEST_TIMEOUT)] equal:@(CMFileCreated)];
});

it(@"should let a user upload a file with a given key", ^{
Expand All @@ -292,19 +292,19 @@
res = response;
}];

[[expectFutureValue(res) shouldEventually] beNonNil];
[[expectFutureValue(res.key) shouldEventually] beNonNil];
[[expectFutureValue(theValue(res.result)) shouldEventually] equal:@(CMFileCreated)];
[[expectFutureValue(res) shouldEventuallyBeforeTimingOutAfter(CM_TEST_TIMEOUT)] beNonNil];
[[expectFutureValue(res.key) shouldEventuallyBeforeTimingOutAfter(CM_TEST_TIMEOUT)] beNonNil];
[[expectFutureValue(theValue(res.result)) shouldEventuallyBeforeTimingOutAfter(CM_TEST_TIMEOUT)] equal:@(CMFileCreated)];
});

it(@"should delete a user file", ^{
__block CMDeleteResponse *res = nil;
[store deleteUserFileNamed:@"my_wonderful_key" additionalOptions:nil callback:^(CMDeleteResponse *response) {
res = response;
}];
[[expectFutureValue(res) shouldEventually] beNonNil];
[[expectFutureValue(res.success) shouldEventually] haveCountOf:1];
[[expectFutureValue(res.success[@"my_wonderful_key"]) shouldEventually] equal:@"deleted"];
[[expectFutureValue(res) shouldEventuallyBeforeTimingOutAfter(CM_TEST_TIMEOUT)] beNonNil];
[[expectFutureValue(res.success) shouldEventuallyBeforeTimingOutAfter(CM_TEST_TIMEOUT)] haveCountOf:1];
[[expectFutureValue(res.success[@"my_wonderful_key"]) shouldEventuallyBeforeTimingOutAfter(CM_TEST_TIMEOUT)] equal:@"deleted"];
});

it(@"should fail to save any ACL's when none are passed", ^{
Expand Down Expand Up @@ -338,9 +338,9 @@
res = response;
}];

[[expectFutureValue(res) shouldEventually] beNonNil];
[[expectFutureValue(res.success) shouldEventually] haveCountOf:1];
[[expectFutureValue(res.success[v.objectId]) shouldEventually] equal:@"deleted"];
[[expectFutureValue(res) shouldEventuallyBeforeTimingOutAfter(CM_TEST_TIMEOUT)] beNonNil];
[[expectFutureValue(res.success) shouldEventuallyBeforeTimingOutAfter(CM_TEST_TIMEOUT)] haveCountOf:1];
[[expectFutureValue(res.success[v.objectId]) shouldEventuallyBeforeTimingOutAfter(CM_TEST_TIMEOUT)] equal:@"deleted"];
});

context(@"with ACL's", ^{
Expand All @@ -355,7 +355,7 @@
otherStore = [CMStore storeWithUser:aclUser];
}];

[[expectFutureValue(theValue([newUser isLoggedIn])) shouldEventually] beTrue];
[[expectFutureValue(theValue([newUser isLoggedIn])) shouldEventuallyBeforeTimingOutAfter(CM_TEST_TIMEOUT)] beTrue];

///
/// Create an object for ACL testing
Expand All @@ -365,8 +365,8 @@
res = response;
}];

[[expectFutureValue(res) shouldEventually] beNonNil];
[[expectFutureValue(res.uploadStatuses) shouldEventually] haveCountOf:1];
[[expectFutureValue(res) shouldEventuallyBeforeTimingOutAfter(CM_TEST_TIMEOUT)] beNonNil];
[[expectFutureValue(res.uploadStatuses) shouldEventuallyBeforeTimingOutAfter(CM_TEST_TIMEOUT)] haveCountOf:1];
});

__block NSString *aclID = nil;
Expand All @@ -385,9 +385,9 @@
res = response;
}];

[[expectFutureValue(res) shouldEventually] beNonNil];
[[expectFutureValue(res.error) shouldEventually] beNil];
[[expectFutureValue(res.uploadStatuses[v.objectId]) shouldEventually] equal:@"updated"];
[[expectFutureValue(res) shouldEventuallyBeforeTimingOutAfter(CM_TEST_TIMEOUT)] beNonNil];
[[expectFutureValue(res.error) shouldEventuallyBeforeTimingOutAfter(CM_TEST_TIMEOUT)] beNil];
[[expectFutureValue(res.uploadStatuses[v.objectId]) shouldEventuallyBeforeTimingOutAfter(CM_TEST_TIMEOUT)] equal:@"updated"];
});

it(@"should add the ACL when a user fetches the objects", ^{
Expand All @@ -401,8 +401,8 @@
[[[v valueForKey:@"sharedACL"] shouldNot] beNil];
}];

[[expectFutureValue(resp) shouldEventually] beNonNil];
[[expectFutureValue(resp.objects) shouldEventually] haveCountOf:1];
[[expectFutureValue(resp) shouldEventuallyBeforeTimingOutAfter(CM_TEST_TIMEOUT)] beNonNil];
[[expectFutureValue(resp.objects) shouldEventuallyBeforeTimingOutAfter(CM_TEST_TIMEOUT)] haveCountOf:1];
});

it(@"should allow the user to search for ACL's", ^{
Expand All @@ -413,9 +413,9 @@
res = response;
}];

[[expectFutureValue(res) shouldEventually] beNonNil];
[[expectFutureValue(res.acls) shouldEventually] beEmpty];
[[expectFutureValue([res permissionsForMember:aclUser.objectId]) shouldEventually] beEmpty];
[[expectFutureValue(res) shouldEventuallyBeforeTimingOutAfter(CM_TEST_TIMEOUT)] beNonNil];
[[expectFutureValue(res.acls) shouldEventuallyBeforeTimingOutAfter(CM_TEST_TIMEOUT)] beEmpty];
[[expectFutureValue([res permissionsForMember:aclUser.objectId]) shouldEventuallyBeforeTimingOutAfter(CM_TEST_TIMEOUT)] beEmpty];
});

it(@"should delete the ACL", ^{
Expand All @@ -424,8 +424,8 @@
res = response;
}];

[[expectFutureValue(res) shouldEventually] beNonNil];
[[expectFutureValue(res.success) shouldEventually] haveCountOf:1];
[[expectFutureValue(res) shouldEventuallyBeforeTimingOutAfter(CM_TEST_TIMEOUT)] beNonNil];
[[expectFutureValue(res.success) shouldEventuallyBeforeTimingOutAfter(CM_TEST_TIMEOUT)] haveCountOf:1];
});
});

Expand Down
Loading

0 comments on commit f673129

Please sign in to comment.