Skip to content

Commit 31b39c7

Browse files
committed
Add test for merge conflict
1 parent e8b2aca commit 31b39c7

File tree

1 file changed

+23
-6
lines changed

1 file changed

+23
-6
lines changed

ObjectiveGitTests/GTRepository+PullSpec.m

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -65,10 +65,8 @@
6565
});
6666

6767
afterEach(^{
68-
[NSFileManager.defaultManager removeItemAtURL:remoteRepoURL error:&error];
69-
expect(error).to(beNil());
70-
[NSFileManager.defaultManager removeItemAtURL:localRepoURL error:&error];
71-
expect(error).to(beNil());
68+
[NSFileManager.defaultManager removeItemAtURL:remoteRepoURL error:NULL];
69+
[NSFileManager.defaultManager removeItemAtURL:localRepoURL error:NULL];
7270
error = NULL;
7371
[self tearDown];
7472
});
@@ -221,13 +219,12 @@
221219

222220
// Pull
223221
__block BOOL transferProgressed = NO;
224-
// FIXME: This is analyzing merge as "up-to-date"
225222
BOOL result = [localRepo pullBranch:masterBranch fromRemote:remote withOptions:nil error:&error progress:^(const git_transfer_progress *progress, BOOL *stop) {
226223
transferProgressed = YES;
227224
}];
228225
expect(@(result)).to(beTruthy());
229226
expect(error).to(beNil());
230-
expect(@(transferProgressed)).to(beTruthy()); // TODO: This one works?
227+
expect(@(transferProgressed)).to(beTruthy());
231228

232229
// Validate
233230

@@ -242,6 +239,26 @@
242239
expect(@(uniqueLocalCommits.count)).to(equal(@3));
243240
});
244241

242+
/// Conflict During Merge
243+
it(@"erupts in a ball of 🔥 with a merge conflict ", ^{
244+
// Stage a conflict by adding the same file with different contents to both repos
245+
GTCommit *localCommit = createCommitInRepository(@"Local commit", [@"TestLocal" dataUsingEncoding:NSUTF8StringEncoding], @"test.txt", localRepo);
246+
expect(localCommit).notTo(beNil());
247+
GTCommit *remoteCommit = createCommitInRepository(@"Upstream commit", [@"TestUpstream" dataUsingEncoding:NSUTF8StringEncoding], @"test.txt", remoteRepo);
248+
expect(remoteCommit).notTo(beNil());
249+
250+
GTBranch *masterBranch = localBranchWithName(@"master", localRepo);
251+
252+
// Pull
253+
__block BOOL transferProgressed = NO;
254+
BOOL result = [localRepo pullBranch:masterBranch fromRemote:remote withOptions:nil error:&error progress:^(const git_transfer_progress *progress, BOOL *stop) {
255+
transferProgressed = YES;
256+
}];
257+
expect(@(result)).to(beFalsy());
258+
expect(error).toNot(beNil());
259+
expect(@(transferProgressed)).to(beTruthy());
260+
});
261+
245262
});
246263

247264
});

0 commit comments

Comments
 (0)