aboutsummaryrefslogtreecommitdiffstats
path: root/storage/filesystem/dotgit/dotgit_test.go
diff options
context:
space:
mode:
authorKyle Evans <kevans@FreeBSD.org>2020-04-23 18:00:03 -0500
committerKyle Evans <kevans@FreeBSD.org>2020-04-23 18:19:08 -0500
commit9c7d576132a760645e3a6b3ebdf51c4aef532794 (patch)
tree0064a4055acf3af0ba0718b41b1554b78bc7fafe /storage/filesystem/dotgit/dotgit_test.go
parent218a744b6995a89f5c322aa58e79138d65392ea6 (diff)
downloadgo-git-9c7d576132a760645e3a6b3ebdf51c4aef532794.tar.gz
storage/filesystem: dotgit, add a test for reading refs from a directory
Specifically, the problem demonstrated is that on some OS (e.g. FreeBSD), read() on a directory will succeed. The current implementation will accept that and return incorrect results, rather than rejecting the directory.
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..403f5ff 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, NotNil)
+
ref, err = dir.Ref("refs/heads/foo")
c.Assert(err, IsNil)
c.Assert(ref, NotNil)