|
22 | 22 | __block NSURL *remoteRepoFileURL; |
23 | 23 | __block NSURL *localRepoURL; |
24 | 24 | __block GTBranch *masterBranch; |
| 25 | + __block GTBranch *remoteMasterBranch; |
25 | 26 |
|
26 | 27 | beforeEach(^{ |
27 | 28 | NSError *error = nil; |
|
39 | 40 | expect(remoteRepo).notTo(beNil()); |
40 | 41 | expect(@(remoteRepo.isBare)).to(beTruthy()); // that's better |
41 | 42 |
|
| 43 | + NSArray *remoteBranches = [remoteRepo localBranchesWithError:&error]; |
| 44 | + expect(error).to(beNil()); |
| 45 | + expect(remoteBranches).notTo(beNil()); |
| 46 | + expect(@(remoteBranches.count)).to(beGreaterThanOrEqualTo(@1)); |
| 47 | + |
| 48 | + remoteMasterBranch = remoteBranches[0]; |
| 49 | + expect(@([remoteMasterBranch numberOfCommitsWithError:NULL])).to(equal(@3)); |
| 50 | + |
42 | 51 | NSURL *remoteRepoFileURL = remoteRepo.gitDirectoryURL; |
43 | 52 | expect(remoteRepoFileURL).notTo(beNil()); |
44 | 53 | NSURL *localRepoURL = [remoteRepoFileURL.URLByDeletingLastPathComponent URLByAppendingPathComponent:@"localpushrepo"]; |
|
62 | 71 | remote = configuration.remotes[0]; |
63 | 72 | expect(remote.name).to(equal(@"origin")); |
64 | 73 |
|
65 | | - // TODO: Verify tracking between local and remote branches |
66 | | - NSArray *branches = [localRepo allBranchesWithError:&error]; |
| 74 | + NSArray *branches = [localRepo localBranchesWithError:&error]; |
67 | 75 | expect(error).to(beNil()); |
68 | 76 | expect(branches).notTo(beNil()); |
| 77 | + expect(@(branches.count)).to(beGreaterThanOrEqualTo(@1)); |
69 | 78 |
|
70 | 79 | masterBranch = branches[0]; |
71 | 80 | expect(masterBranch.shortName).to(equal(@"master")); |
| 81 | + expect(@([masterBranch numberOfCommitsWithError:NULL])).to(equal(@3)); |
72 | 82 | }); |
73 | 83 |
|
74 | 84 | afterEach(^{ |
|
101 | 111 | it(@"pushes nothing when the branch on local and remote are in sync", ^{ |
102 | 112 | NSError *error = nil; |
103 | 113 |
|
| 114 | + expect(@([remoteMasterBranch numberOfCommitsWithError:NULL])).to(equal(@3)); |
| 115 | + |
104 | 116 | __block BOOL transferProgressed = NO; |
105 | 117 | BOOL result = [localRepo pushBranch:masterBranch toRemote:remote withOptions:nil error:&error progress:^(unsigned int current, unsigned int total, size_t bytes, BOOL *stop) { |
106 | 118 | transferProgressed = YES; |
107 | 119 | }]; |
108 | 120 | expect(error).to(beNil()); |
109 | 121 | expect(@(result)).to(beTruthy()); |
110 | 122 | expect(@(transferProgressed)).to(beFalse()); // Local transport doesn't currently call progress callbacks |
| 123 | + |
| 124 | + // Same number of commits after push |
| 125 | + expect(@([remoteMasterBranch numberOfCommitsWithError:NULL])).to(equal(@3)); |
111 | 126 | }); |
112 | 127 |
|
113 | 128 | it(@"pushes a new local commit to the remote", ^{ |
|
119 | 134 | GTCommit *testCommit = createCommitInRepository(@"Test commit", [testData dataUsingEncoding:NSUTF8StringEncoding], fileName, localRepo); |
120 | 135 | expect(testCommit).notTo(beNil()); |
121 | 136 |
|
| 137 | + // Refetch master branch to ensure the commit count is accurate |
| 138 | + masterBranch = [localRepo localBranchesWithError:NULL][0]; |
| 139 | + expect(@([masterBranch numberOfCommitsWithError:NULL])).to(equal(@4)); |
| 140 | + |
| 141 | + // Number of commits on remote before push |
| 142 | + expect(@([remoteMasterBranch numberOfCommitsWithError:NULL])).to(equal(@3)); |
| 143 | + |
122 | 144 | // Push |
123 | 145 | __block BOOL transferProgressed = NO; |
124 | 146 | BOOL result = [localRepo pushBranch:masterBranch toRemote:remote withOptions:nil error:&error progress:^(unsigned int current, unsigned int total, size_t bytes, BOOL *stop) { |
|
128 | 150 | expect(@(result)).to(beTruthy()); |
129 | 151 | expect(@(transferProgressed)).to(beFalse()); // Local transport doesn't currently call progress callbacks |
130 | 152 |
|
| 153 | + // Refetch master branch to ensure the commit count is accurate |
| 154 | + remoteMasterBranch = [remoteRepo localBranchesWithError:NULL][0]; |
| 155 | + |
| 156 | + // Number of commits on remote after push |
| 157 | + expect(@([remoteMasterBranch numberOfCommitsWithError:NULL])).to(equal(@4)); |
| 158 | + |
131 | 159 | // Verify commit is in remote |
132 | 160 | GTCommit *pushedCommit = [remoteRepo lookUpObjectByOID:testCommit.OID objectType:GTObjectTypeCommit error:&error]; |
133 | 161 | expect(error).to(beNil()); |
|
0 commit comments