Skip to content

Commit 7b2fd5b

Browse files
mattyclarksonJohn Haley
authored andcommitted
Unit testing for repository.createLightweightTag
1 parent 1a3b1fa commit 7b2fd5b

File tree

1 file changed

+35
-0
lines changed

1 file changed

+35
-0
lines changed

test/tests/tag.js

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,4 +109,39 @@ describe("Tag", function() {
109109
return Promise.resolve();
110110
});
111111
});
112+
113+
it("can create a new lightweight tag in a repo and delete it", function() {
114+
var oid = Oid.fromString(commitPointedTo);
115+
var name = "created-lightweight-tag";
116+
var repository = this.repository;
117+
118+
return repository.createLightweightTag(oid, name)
119+
.then(function(reference) {
120+
return reference.target();
121+
})
122+
.then(function(refOid) {
123+
assert.equal(refOid.toString(), oid.toString());
124+
})
125+
.then(function() {
126+
return repository.createLightweightTag(oid, name);
127+
})
128+
.then(function() {
129+
return Promise.reject(new Error("should not be able to create the '" +
130+
name + "' tag twice"));
131+
}, function() {
132+
return Promise.resolve();
133+
})
134+
.then(function() {
135+
return repository.deleteTagByName(name);
136+
})
137+
.then(function() {
138+
return Reference.lookup(repository, "refs/tags/" + name);
139+
})
140+
.then(function() {
141+
return Promise.reject(new Error("the tag '" + name +
142+
"' should not exist"));
143+
}, function() {
144+
return Promise.resolve();
145+
});
146+
});
112147
});

0 commit comments

Comments
 (0)