Skip to content
This repository was archived by the owner on Sep 11, 2020. It is now read-only.

Commit 681855b

Browse files
committed
storage/dotgit: test setRef with a non rwfs
Signed-off-by: Javi Fontan <jfontan@gmail.com>
1 parent 46c0d2e commit 681855b

File tree

1 file changed

+24
-1
lines changed

1 file changed

+24
-1
lines changed

storage/filesystem/dotgit/dotgit_test.go

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,11 +57,26 @@ func (s *SuiteDotGit) TestSetRefs(c *C) {
5757
fs := osfs.New(tmp)
5858
dir := New(fs)
5959

60+
testSetRefs(c, dir)
61+
}
62+
63+
func (s *SuiteDotGit) TestSetRefsNorwfs(c *C) {
64+
tmp, err := ioutil.TempDir("", "dot-git")
65+
c.Assert(err, IsNil)
66+
defer os.RemoveAll(tmp)
67+
68+
fs := osfs.New(tmp)
69+
dir := New(&norwfs{fs})
70+
71+
testSetRefs(c, dir)
72+
}
73+
74+
func testSetRefs(c *C, dir *DotGit) {
6075
firstFoo := plumbing.NewReferenceFromStrings(
6176
"refs/heads/foo",
6277
"e8d3ffab552895c19b9fcf7aa264d277cde33881",
6378
)
64-
err = dir.SetRef(firstFoo, nil)
79+
err := dir.SetRef(firstFoo, nil)
6580

6681
c.Assert(err, IsNil)
6782

@@ -795,3 +810,11 @@ func (s *SuiteDotGit) TestAlternates(c *C) {
795810
}
796811
c.Assert(dotgits[1].fs.Root(), Equals, expectedPath)
797812
}
813+
814+
type norwfs struct {
815+
billy.Filesystem
816+
}
817+
818+
func (f *norwfs) Capabilities() billy.Capability {
819+
return billy.Capabilities(f.Filesystem) &^ billy.ReadAndWriteCapability
820+
}

0 commit comments

Comments
 (0)