Commit fab9237a authored by Tim's avatar Tim Committed by John Haley

Enable note foreach and remove async

And added testing goodness!
parent f0f8dfef
......@@ -273,7 +273,11 @@
"git_note_foreach_cb": {
"args": [
{
"name": "id",
"name": "blob_id",
"cType": "const git_oid *"
},
{
"name": "annotated_object_id",
"cType": "const git_oid *"
},
{
......@@ -283,7 +287,7 @@
],
"return": {
"type": "int",
"noResults": 1,
"noResults": 0,
"success": 0,
"error": -1
}
......
......@@ -960,8 +960,17 @@
}
}
},
"git_note_remove": {
"isAsync": true,
"return": {
"isErrorCode": true
}
},
"git_note_foreach": {
"ignore": true
"isAsync": true,
"return": {
"isErrorCode": true
}
}
}
},
......
var NodeGit = require("../");
var Note = NodeGit.Note;
// Override Note.foreach to eliminate the need to pass null payload
var foreach = Note.foreach;
Note.foreach = function(repo, notesRef, callback) {
return foreach(repo, notesRef, callback, null);
};
......@@ -6,7 +6,7 @@ describe("Note", function() {
var NodeGit = require("../../");
var Note = NodeGit.Note;
var Signature = NodeGit.Signature;
var reposPath = local("../repos/merge");
var reposPath = local("../../");
beforeEach(function() {
var test = this;
......@@ -37,16 +37,33 @@ describe("Note", function() {
});
});
it("can iterate all notes", function() {
var test = this;
var noteRef = "refs/notes/commits";
var ref = null;
return Note.foreach(this.repository, noteRef, function(blobId, objectId) {
ref = objectId;
}).then(function() {
return NodeGit.Note.read(test.repository, noteRef, ref)
.then(function(note) {
assert.equal(note.message(), "Testing!");
});
});
});
it("can be removed", function(done) {
var test = this;
var sha = this.commit.id();
var noteRef = "refs/notes/commits";
var sig = Signature.create("John", "john@doe.com", Date.now(), 0);
Note.remove(this.repository, noteRef, sig, sig, sha);
return Note.read(this.repository, noteRef, sha).catch(function(ex) {
assert.equal(ex.message, "Note could not be found");
done();
});
return Note.remove(this.repository, noteRef, sig, sig, sha)
.then(function() {
return Note.read(test.repository, noteRef, sha).catch(function(ex) {
assert.equal(ex.message, "Note could not be found");
done();
});
});
});
});
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