summaryrefslogtreecommitdiff
path: root/reference_test.go
diff options
context:
space:
mode:
authorCalin Seciu <[email protected]>2015-07-24 12:14:24 +0300
committerCalin Seciu <[email protected]>2015-07-24 12:14:24 +0300
commit4b88210cbf495891c8d44c53b3d978e6ff31a5a3 (patch)
tree3a205d0122b46ccf6105c225dcbb7a97e942bf5e /reference_test.go
parent28dee704cafd347599ae55f30441275b219def03 (diff)
Add check if reference is a note
Diffstat (limited to 'reference_test.go')
-rw-r--r--reference_test.go32
1 files changed, 32 insertions, 0 deletions
diff --git a/reference_test.go b/reference_test.go
index f1546e2..b69a274 100644
--- a/reference_test.go
+++ b/reference_test.go
@@ -176,6 +176,38 @@ func TestUtil(t *testing.T) {
}
}
+func TestIsNote(t *testing.T) {
+ repo := createTestRepo(t)
+ defer cleanupTestRepo(t, repo)
+
+ commitID, _ := seedTestRepo(t, repo)
+
+ sig := &Signature{
+ Name: "Rand Om Hacker",
+ Email: "[email protected]",
+ When: time.Now(),
+ }
+
+ refname, err := repo.Notes.DefaultRef()
+ checkFatal(t, err)
+
+ _, err = repo.Notes.Create(refname, sig, sig, commitID, "This is a note", false)
+ checkFatal(t, err)
+
+ ref, err := repo.References.Lookup(refname)
+ checkFatal(t, err)
+
+ if !ref.IsNote() {
+ t.Fatalf("%s should be a note", ref.Name())
+ }
+
+ ref, err = repo.References.Create("refs/heads/foo", commitID, true, "")
+ checkFatal(t, err)
+
+ if ref.IsNote() {
+ t.Fatalf("%s should not be a note", ref.Name())
+ }
+}
func compareStringList(t *testing.T, expected, actual []string) {
for i, v := range expected {
if actual[i] != v {