Commit c1a07f06 authored by Carson Howard's avatar Carson Howard

Updated descriptors for git_index_find and git_index_find_prefix

parent 7ac21198
......@@ -1213,7 +1213,28 @@
"jsFunctionName": "entryCount"
},
"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": {
"ignore": true
......
......@@ -13,6 +13,7 @@ describe("Index", function() {
var RepoUtils = require("../utils/repository_setup");
var NodeGit = require("../../");
var Repository = NodeGit.Repository;
var ErrorCodes = NodeGit.Error.CODE;
var reposPath = local("../repos/workdir");
......@@ -359,4 +360,67 @@ describe("Index", function() {
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