summaryrefslogtreecommitdiff
path: root/tag_test.go
diff options
context:
space:
mode:
authorFrank Benkstein <[email protected]>2014-06-09 23:19:17 +0200
committerFrank Benkstein <[email protected]>2014-06-09 23:19:17 +0200
commitbbdc7a825d1c7e65516cbc92e72335bf1f35c2f0 (patch)
tree878f12f83c0701cd849c0458deb29cf2273735f4 /tag_test.go
parent3ca566e105e8156a2583f36e9dd9e06ed3b3564c (diff)
add support for annotated tags
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
+}