Commit 5eff9257 authored by Tyler Wanek's avatar Tyler Wanek Committed by GitHub

Merge pull request #1391 from cjhoward92/fix/index-find-prefix

Updated descriptors for git_index_find and git_index_find_prefix
parents 7ac21198 c1a07f06
...@@ -1213,7 +1213,28 @@ ...@@ -1213,7 +1213,28 @@
"jsFunctionName": "entryCount" "jsFunctionName": "entryCount"
}, },
"git_index_find": { "git_index_find": {
"ignore": true "isAsync": true,
"args": {
"at_pos": {
"isReturn": true,
"shouldAlloc": true
}
},
"return": {
"isErrorCode": true
}
},
"git_index_find_prefix": {
"isAsync": true,
"args": {
"at_pos": {
"isReturn": true,
"shouldAlloc": true
}
},
"return": {
"isErrorCode": true
}
}, },
"git_index_free": { "git_index_free": {
"ignore": true "ignore": true
......
...@@ -13,6 +13,7 @@ describe("Index", function() { ...@@ -13,6 +13,7 @@ describe("Index", function() {
var RepoUtils = require("../utils/repository_setup"); var RepoUtils = require("../utils/repository_setup");
var NodeGit = require("../../"); var NodeGit = require("../../");
var Repository = NodeGit.Repository; var Repository = NodeGit.Repository;
var ErrorCodes = NodeGit.Error.CODE;
var reposPath = local("../repos/workdir"); var reposPath = local("../repos/workdir");
...@@ -359,4 +360,67 @@ describe("Index", function() { ...@@ -359,4 +360,67 @@ describe("Index", function() {
assert(index.hasConflicts()); assert(index.hasConflicts());
}); });
}); });
it("can find the specified file in the index", function() {
var test = this;
return test.index.find("src/wrapper.cc")
.then(function(position) {
assert.notEqual(position, null);
});
});
it("cannot find the specified file in the index", function() {
var test = this;
return test.index.find("src/thisisfake.cc")
.then(function(position) {
assert.fail("the item should not be found");
})
.catch(function(error) {
assert.strictEqual(error.errno, ErrorCodes.ENOTFOUND);
});
});
it("cannot find the directory in the index", function() {
var test = this;
return test.index.find("src")
.then(function(position) {
assert.fail("the item should not be found");
})
.catch(function(error) {
assert.strictEqual(error.errno, ErrorCodes.ENOTFOUND);
});
});
it("can find the specified prefix in the index", function() {
var test = this;
return test.index.findPrefix("src/")
.then(function(position) {
assert.notEqual(position, null);
});
});
it("cannot find the specified prefix in the index", function() {
var test = this;
return test.index.find("testing123/")
.then(function(position) {
assert.fail("the item should not be found");
})
.catch(function(error) {
assert.strictEqual(error.errno, ErrorCodes.ENOTFOUND);
});
});
it("can find the prefix when a file shares the name", function() {
var test = this;
return test.index.find("LICENSE")
.then(function(position) {
assert.notEqual(position, null);
});
});
}); });
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment