Skip to content

Instantly share code, notes, and snippets.

@markcerqueira
Last active August 30, 2016 00:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save markcerqueira/2d4197539f3b335436219e19074c8186 to your computer and use it in GitHub Desktop.
Save markcerqueira/2d4197539f3b335436219e19074c8186 to your computer and use it in GitHub Desktop.
Snippet of ChuckPadServiceTests.m from markcerqueira/hello-chuckpad
// 1 - Create a new user so we can upload patches
XCTestExpectation *expectation1 = [self expectationWithDescription:@"createUser timed out (1)"];
[[ChuckPadSocial sharedInstance] createUser:user.username email:user.email password:user.password callback:^(BOOL succeeded, NSError *error) {
[self doPostAuthAssertChecks:user];
[expectation1 fulfill];
}];
[self waitForExpectations];
// 2 - Upload a new patch
ChuckPadPatch *localPatch = [ChuckPadPatch generatePatch:@"demo0.ck"];
XCTestExpectation *expectation2 = [self expectationWithDescription:@"uploadPatch timed out (2)"];
[[ChuckPadSocial sharedInstance] uploadPatch:localPatch.name description:localPatch.patchDescription parent:-1 filename:localPatch.filename fileData:localPatch.fileData callback:^(BOOL succeeded, Patch *patch, NSError *error) {
user.totalPatches++;
XCTAssertTrue(succeeded);
// Assert our username and owner username of patch match and once we confirm that is the case, update our local
// user object with its user id.
XCTAssertTrue([patch.creatorUsername isEqualToString:user.username]);
[user updateUserId:patch.creatorId];
[self assertPatch:patch localPatch:localPatch isConsistentForUser:user];
[expectation2 fulfill];
}];
[self waitForExpectations];
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment