Skip to content

Commit

Permalink
Updated descriptors for git_index_find and git_index_find_prefix
Browse files Browse the repository at this point in the history
  • Loading branch information
Carson Howard committed Oct 16, 2017
1 parent 7ac2119 commit c1a07f0
Show file tree
Hide file tree
Showing 2 changed files with 86 additions and 1 deletion.
23 changes: 22 additions & 1 deletion generate/input/descriptor.json
Expand Up @@ -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
Expand Down
64 changes: 64 additions & 0 deletions test/tests/index.js
Expand Up @@ -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");

Expand Down Expand Up @@ -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);
});
});
});

0 comments on commit c1a07f0

Please sign in to comment.