Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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
You can’t perform that action at this time.