From bbdc7a825d1c7e65516cbc92e72335bf1f35c2f0 Mon Sep 17 00:00:00 2001 From: Frank Benkstein Date: Mon, 9 Jun 2014 23:19:17 +0200 Subject: add support for annotated tags --- tag_test.go | 45 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 tag_test.go (limited to 'tag_test.go') 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: "random@hacker.com", + 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 +} -- cgit v1.2.3