aboutsummaryrefslogtreecommitdiffstats
path: root/storage/filesystem/dotgit/dotgit_test.go
diff options
context:
space:
mode:
authorMáximo Cuadros <mcuadros@gmail.com>2020-04-24 14:05:39 +0200
committerGitHub <noreply@github.com>2020-04-24 14:05:39 +0200
commitc9533a6f9f3a6edd0fb7c8c161d4016a6af26bc3 (patch)
tree2046075da6803e110c9d6272d0f49f9f7020d7d3 /storage/filesystem/dotgit/dotgit_test.go
parent218a744b6995a89f5c322aa58e79138d65392ea6 (diff)
parent63967abe62ecba22a792e728f1af509f3604881f (diff)
downloadgo-git-c9533a6f9f3a6edd0fb7c8c161d4016a6af26bc3.tar.gz
Merge pull request #39 from kevans91/fixread
storage/filesystem: dotgit, sanity check provided reference path
Diffstat (limited to 'storage/filesystem/dotgit/dotgit_test.go')
-rw-r--r--storage/filesystem/dotgit/dotgit_test.go14
1 files changed, 13 insertions, 1 deletions
diff --git a/storage/filesystem/dotgit/dotgit_test.go b/storage/filesystem/dotgit/dotgit_test.go
index d57ff15..519f601 100644
--- a/storage/filesystem/dotgit/dotgit_test.go
+++ b/storage/filesystem/dotgit/dotgit_test.go
@@ -93,9 +93,15 @@ func testSetRefs(c *C, dir *DotGit) {
), nil)
c.Assert(err, IsNil)
+ err = dir.SetRef(plumbing.NewReferenceFromStrings(
+ "refs/heads/feature/baz",
+ "e8d3ffab552895c19b9fcf7aa264d277cde33881",
+ ), nil)
+ c.Assert(err, IsNil)
+
refs, err := dir.Refs()
c.Assert(err, IsNil)
- c.Assert(refs, HasLen, 2)
+ c.Assert(refs, HasLen, 3)
ref := findReference(refs, "refs/heads/foo")
c.Assert(ref, NotNil)
@@ -108,6 +114,12 @@ func testSetRefs(c *C, dir *DotGit) {
ref = findReference(refs, "bar")
c.Assert(ref, IsNil)
+ _, err = dir.readReferenceFile(".", "refs/heads/feature/baz")
+ c.Assert(err, IsNil)
+
+ _, err = dir.readReferenceFile(".", "refs/heads/feature")
+ c.Assert(err, Equals, ErrIsDir)
+
ref, err = dir.Ref("refs/heads/foo")
c.Assert(err, IsNil)
c.Assert(ref, NotNil)