summaryrefslogtreecommitdiff
path: root/tag_test.go
diff options
context:
space:
mode:
authorCarlos Martín Nieto <[email protected]>2014-07-03 08:37:23 +0200
committerCarlos Martín Nieto <[email protected]>2014-07-03 08:37:23 +0200
commitd117fc9aa8b727a59fbdf7b1aa3bd87c60331b6a (patch)
tree834ec9e204148ca901b7daef3c9af9dfbbb3a922 /tag_test.go
parentae5efcda9be2054734cdc3399a85e6f2ddceacff (diff)
parentb3306bee412e29558ac334d2a4bbc0be7d85e2d5 (diff)
Merge commit 'refs/pull/95/head' of github.com:libgit2/git2go
Diffstat (limited to 'tag_test.go')
-rw-r--r--tag_test.go45
1 files changed, 45 insertions, 0 deletions
diff --git a/tag_test.go b/tag_test.go
new file mode 100644
index 0000000..5ebd53d
--- /dev/null
+++ b/tag_test.go
@@ -0,0 +1,45 @@
+package git
+
+import (
+ "os"
+ "time"
+ "testing"
+)
+
+func TestCreateTag(t *testing.T) {
+ repo := createTestRepo(t)
+ defer os.RemoveAll(repo.Workdir())
+ commitId, _ := seedTestRepo(t, repo)
+
+ commit, err := repo.LookupCommit(commitId)
+ checkFatal(t, err)
+
+ tagId := createTestTag(t, repo, commit)
+
+ tag, err := repo.LookupTag(tagId)
+ checkFatal(t, err)
+
+ compareStrings(t, "v0.0.0", tag.Name())
+ compareStrings(t, "This is a tag", tag.Message())
+ compareStrings(t, commitId.String(), tag.TargetId().String())
+}
+
+func compareStrings(t *testing.T, expected, value string) {
+ if value != expected {
+ t.Fatalf("expected '%v', actual '%v'", expected, value)
+ }
+}
+
+func createTestTag(t *testing.T, repo *Repository, commit *Commit) *Oid {
+ loc, err := time.LoadLocation("Europe/Berlin")
+ checkFatal(t, err)
+ sig := &Signature{
+ Name: "Rand Om Hacker",
+ Email: "[email protected]",
+ When: time.Date(2013, 03, 06, 14, 30, 0, 0, loc),
+ }
+
+ tagId, err := repo.CreateTag("v0.0.0", commit, sig, "This is a tag")
+ checkFatal(t, err)
+ return tagId
+}