diff options
| author | Carlos Martín Nieto <[email protected]> | 2014-02-26 14:51:04 +0100 |
|---|---|---|
| committer | Carlos Martín Nieto <[email protected]> | 2014-02-26 14:51:04 +0100 |
| commit | ca2c3c6db287f469736ff635167cd54f29b8a067 (patch) | |
| tree | 43a7e034fc0ea40cbe91e98c8badd91b375da36d /reference_test.go | |
| parent | 786393a380e17e1e0bc47fea97cbe18c8c0ebb22 (diff) | |
Add a few reference utility functions
Diffstat (limited to 'reference_test.go')
| -rw-r--r-- | reference_test.go | 27 |
1 files changed, 27 insertions, 0 deletions
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 { |
