Skip to content

Commit 8ec7a58

Browse files
committed
Merge pull request #936 from smith-kyle/test-index-utils
Tests: generalized createConflict in index utils
2 parents d8f1dae + 6608751 commit 8ec7a58

File tree

2 files changed

+12
-16
lines changed

2 files changed

+12
-16
lines changed

test/tests/index.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -311,7 +311,7 @@ describe("Index", function() {
311311

312312
it("can add a conflict to the index", function() {
313313
var repo;
314-
var repoPath = path.join(__dirname, "..", "repos", "index");
314+
var repoPath = local("../repos/index");
315315
var ourBranchName = "ours";
316316
var theirBranchName = "theirs";
317317
var fileName = "testFile.txt";
@@ -329,6 +329,10 @@ describe("Index", function() {
329329
fileName
330330
);
331331
})
332+
.then(function(index) {
333+
assert.ok(index.hasConflicts());
334+
return index.conflictGet(fileName);
335+
})
332336
.then(function(indexEntries) {
333337
// Store all indexEntries for conflict
334338
ancestorIndexEntry = indexEntries.ancestor_out;

test/utils/index_setup.js

Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
var assert = require("assert");
21
var NodeGit = require("../../");
32
var path = require("path");
43
var promisify = require("promisify-node");
@@ -75,25 +74,18 @@ var IndexSetup = {
7574
return repository.createCommit(ourBranch.name(), ourSignature,
7675
ourSignature, "we made a commit", oid, [ourCommit]);
7776
})
78-
.then(function(commitOid) {
79-
var opts = {
80-
checkoutStrategy: NodeGit.Checkout.STRATEGY.FORCE
81-
};
82-
83-
return NodeGit.Checkout.head(repository, opts);
77+
.then(function() {
78+
return repository.checkoutBranch(
79+
ourBranch,
80+
new NodeGit.CheckoutOptions()
81+
);
8482
})
8583
.then(function() {
8684
return repository.mergeBranches(ourBranchName, theirBranchName);
8785
})
88-
.then(function(commit) {
89-
assert.fail(commit, undefined,
90-
"The index should have been thrown due to merge conflicts");
91-
})
9286
.catch(function(index) {
93-
assert.ok(index);
94-
assert.ok(index.hasConflicts());
95-
96-
return index.conflictGet(fileName);
87+
return NodeGit.Checkout.index(repository, index)
88+
.then(function() { return index; });
9789
});
9890
}
9991
};

0 commit comments

Comments
 (0)