diff options
Diffstat (limited to 'reference_test.go')
| -rw-r--r-- | reference_test.go | 46 |
1 files changed, 39 insertions, 7 deletions
diff --git a/reference_test.go b/reference_test.go index f955a2c..ffa9f35 100644 --- a/reference_test.go +++ b/reference_test.go @@ -14,7 +14,14 @@ func TestRefModification(t *testing.T) { commitId, treeId := seedTestRepo(t, repo) - _, err := repo.CreateReference("refs/tags/tree", treeId, true) + 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), + } + _, err = repo.CreateReference("refs/tags/tree", treeId, true, sig, "testTreeTag") checkFatal(t, err) tag, err := repo.LookupReference("refs/tags/tree") @@ -45,7 +52,7 @@ func TestRefModification(t *testing.T) { t.Fatalf("Wrong ref target") } - _, err = tag.Rename("refs/tags/renamed", false) + _, err = tag.Rename("refs/tags/renamed", false, nil, "") checkFatal(t, err) tag, err = repo.LookupReference("refs/tags/renamed") checkFatal(t, err) @@ -78,13 +85,13 @@ func TestIterator(t *testing.T) { commitId, err := repo.CreateCommit("HEAD", sig, sig, message, tree) checkFatal(t, err) - _, err = repo.CreateReference("refs/heads/one", commitId, true) + _, err = repo.CreateReference("refs/heads/one", commitId, true, sig, "headOne") checkFatal(t, err) - _, err = repo.CreateReference("refs/heads/two", commitId, true) + _, err = repo.CreateReference("refs/heads/two", commitId, true, sig, "headTwo") checkFatal(t, err) - _, err = repo.CreateReference("refs/heads/three", commitId, true) + _, err = repo.CreateReference("refs/heads/three", commitId, true, sig, "headThree") checkFatal(t, err) iter, err := repo.NewReferenceIterator() @@ -108,7 +115,6 @@ func TestIterator(t *testing.T) { t.Fatal("Iteration not over") } - sort.Strings(list) compareStringList(t, expected, list) @@ -129,7 +135,6 @@ func TestIterator(t *testing.T) { t.Fatalf("Wrong number of references returned %v", count) } - // test the channel iteration list = []string{} iter, err = repo.NewReferenceIterator() @@ -154,6 +159,33 @@ func TestIterator(t *testing.T) { compareStringList(t, expected, list) } +func TestUtil(t *testing.T) { + repo := createTestRepo(t) + defer os.RemoveAll(repo.Workdir()) + + commitId, _ := seedTestRepo(t, repo) + + ref, err := repo.CreateReference("refs/heads/foo", commitId, true, nil, "") + checkFatal(t, err) + + ref2, err := repo.DwimReference("foo") + checkFatal(t, err) + + if ref.Cmp(ref2) != 0 { + t.Fatalf("foo didn't dwim to the right thing") + } + + if ref.Shorthand() != "foo" { + t.Fatalf("refs/heads/foo has no foo shorthand") + } + + hasLog, err := repo.HasLog("refs/heads/foo") + checkFatal(t, err) + if !hasLog { + t.Fatalf("branches ahve logs by default") + } +} + func compareStringList(t *testing.T, expected, actual []string) { for i, v := range expected { if actual[i] != v { |
