Skip to content

Commit e340fd5

Browse files
committed
Test -branches:.
1 parent c2a2b4d commit e340fd5

File tree

1 file changed

+52
-0
lines changed

1 file changed

+52
-0
lines changed

ObjectiveGitTests/GTRepositorySpec.m

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -490,6 +490,58 @@
490490
});
491491
});
492492

493+
describe(@"-branches:", ^{
494+
__block NSArray *branches;
495+
496+
beforeEach(^{
497+
GTRepository *repository = [self testAppForkFixtureRepository];
498+
branches = [repository branches:NULL];
499+
expect(branches).notTo(beNil());
500+
});
501+
502+
it(@"should combine a local branch with its remote branch", ^{
503+
NSMutableArray *localBranchAs = [NSMutableArray array];
504+
NSMutableArray *remoteBranchAs = [NSMutableArray array];
505+
for (GTBranch *branch in branches) {
506+
if ([branch.shortName isEqual:@"BranchA"]) {
507+
if (branch.branchType == GTBranchTypeLocal) {
508+
[localBranchAs addObject:branch];
509+
} else {
510+
[remoteBranchAs addObject:branch];
511+
}
512+
}
513+
}
514+
515+
expect(@(localBranchAs.count)).to(equal(@1));
516+
517+
GTBranch *localBranchA = localBranchAs[0];
518+
GTBranch *trackingBranch = [localBranchA trackingBranchWithError:NULL success:NULL];
519+
expect(trackingBranch.remoteName).to(equal(@"origin"));
520+
521+
expect(@(remoteBranchAs.count)).to(equal(@1));
522+
523+
GTBranch *remoteBranchA = remoteBranchAs[0];
524+
expect(remoteBranchA.remoteName).to(equal(@"github"));
525+
});
526+
527+
it(@"should contain local branches", ^{
528+
NSInteger index = [branches indexOfObjectPassingTest:^BOOL(GTBranch *branch, NSUInteger idx, BOOL *stop) {
529+
return [branch.shortName isEqual:@"new-shite"];
530+
}];
531+
expect(@(index)).notTo(equal(@(NSNotFound)));
532+
});
533+
534+
it(@"should contain remote branches which exist on multiple remotes", ^{
535+
NSUInteger matches = 0;
536+
for (GTBranch *branch in branches) {
537+
if ([branch.shortName isEqual:@"blah"] && branch.branchType == GTBranchTypeRemote) {
538+
matches++;
539+
}
540+
}
541+
expect(@(matches)).to(equal(@2));
542+
});
543+
});
544+
493545
afterEach(^{
494546
[self tearDown];
495547
});

0 commit comments

Comments
 (0)