FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Added tests for Tag by rcjsuen · Pull Request #1180 · nodegit/nodegit · GitHub

Repository navigation

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension .js  (1) All 1 file type selected
Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
76 changes: 76 additions & 0 deletions test/tests/tag.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,14 @@ describe("Tag", function() {
var Obj = NodeGit.Object;
var Oid = NodeGit.Oid;
var Reference = NodeGit.Reference;
var Signature = NodeGit.Signature;

var reposPath = local("../repos/workdir");
var tagName = "annotated-tag";
var tagFullName = "refs/tags/" + tagName;
var tagOid = "dc800017566123ff3c746b37284a24a66546667e";
var commitPointedTo = "32789a79e71fbc9e04d3eff7425e1771eb595150";
var commitPointedTo2 = "c82fb078a192ea221c9f1093c64321c60d64aa0d";
var tagMessage = "This is an annotated tag\n";

function testTag(tag, name) {
Expand Down Expand Up @@ -144,4 +146,78 @@ describe("Tag", function() {
return Promise.resolve();
});
});

it("can create a new signed tag with Tag.create and delete it", function() {
var name = "created-signed-tag-create";
var repository = this.repository;
var signature = Signature.default(repository);
var commit = null;
var commit2 = null;

return repository.getCommit(commitPointedTo)
.then(function(theCommit) {
commit = theCommit;
return repository.getCommit(commitPointedTo2);
})
.then(function(theCommit2) {
commit2 = theCommit2;
return Tag.create(repository, name, commit, signature, tagMessage, 1);
})
.then(function(oid) {
return repository.getTag(oid);
})
.then(function(tag) {
testTag(tag, name);
assert(tag.tagger(), signature);
})
.then(function() {
// overwriting is okay
return Tag.create(repository, name, commit2, signature, tagMessage, 1);
})
.then(function() {
// overwriting is not okay
return Tag.create(repository, name, commit, signature, tagMessage, 0);
})
.then(function() {
return Promise.reject(new Error("should not be able to create the '" +
name + "' tag twice"));
}, function() {
return Promise.resolve()
.then(function() {
return repository.deleteTagByName(name);
})
.then(function() {
return Reference.lookup(repository, "refs/tags/" + name);
})
.then(function() {
return Promise.reject(new Error("the tag '" + name +
"' should not exist"));
}, function() {
return Promise.resolve();
});
});
});

it("can create a new signed tag with Tag.annotationCreate", function() {
var oid = Oid.fromString(commitPointedTo);
var name = "created-signed-tag-annotationCreate";
var repository = this.repository;
var signature = Signature.default(repository);
var odb = null;

return repository.odb()
.then(function(theOdb) {
odb = theOdb;
})
.then(function() {
return Tag.annotationCreate(
repository, name, oid, signature, tagMessage);
})
.then(function(oid) {
return odb.read(oid);
})
.then(function(object) {
assert(object.type(), Obj.TYPE.TAG);
});
});
});

Back | FazBrowse Home | New Git URL