From ca2c3c6db287f469736ff635167cd54f29b8a067 Mon Sep 17 00:00:00 2001 From: Carlos Martín Nieto Date: Wed, 26 Feb 2014 14:51:04 +0100 Subject: Add a few reference utility functions --- reference_test.go | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) (limited to 'reference_test.go') diff --git a/reference_test.go b/reference_test.go index 156960a..ffa9f35 100644 --- a/reference_test.go +++ b/reference_test.go @@ -159,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 { -- cgit v1.2.3