Skip to content

Commit 29c6083

Browse files
mattyclarksonJohn Haley
authored andcommitted
Unit tests for Repository.createTag
1 parent 0057e47 commit 29c6083

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed

test/tests/tag.js

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ describe("Tag", function() {
77
var Tag = require(local("../../lib/tag"));
88
var Obj = require(local("../../lib/object"));
99
var Oid = require(local("../../lib/oid"));
10+
var Reference = require(local("../../lib/reference"));
11+
var Promise = require("nodegit-promise");
1012

1113
var reposPath = local("../repos/workdir/.git");
1214
var tagName = "annotated-tag";
@@ -75,4 +77,36 @@ describe("Tag", function() {
7577
assert.equal(tagNames.length, 1);
7678
});
7779
});
80+
81+
it("can create a new annotated tag in a repo and delete it", function() {
82+
var oid = Oid.fromString(commitPointedTo);
83+
var name = "created-annotated-tag";
84+
var repository = this.repository;
85+
86+
return repository.createTag(oid, name, tagMessage)
87+
.then(function(tag) {
88+
testTag(tag, name);
89+
})
90+
.then(function() {
91+
return repository.createTag(oid, name, tagMessage);
92+
})
93+
.then(function() {
94+
return Promise.reject(new Error("should not be able to create the '" +
95+
name + "' tag twice"));
96+
}, function() {
97+
return Promise.resolve();
98+
})
99+
.then(function() {
100+
return repository.deleteTagByName(name);
101+
})
102+
.then(function() {
103+
return Reference.lookup(repository, "refs/tags/" + name);
104+
})
105+
.then(function() {
106+
return Promise.reject(new Error("the tag '" + name +
107+
"' should not exist"));
108+
}, function() {
109+
return Promise.resolve();
110+
});
111+
});
78112
});

0 commit comments

Comments
 (0)