aboutsummaryrefslogtreecommitdiffstats
path: root/storage/filesystem/storage_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'storage/filesystem/storage_test.go')
-rw-r--r--storage/filesystem/storage_test.go23
1 files changed, 17 insertions, 6 deletions
diff --git a/storage/filesystem/storage_test.go b/storage/filesystem/storage_test.go
index 20eead0..096c37a 100644
--- a/storage/filesystem/storage_test.go
+++ b/storage/filesystem/storage_test.go
@@ -1,15 +1,16 @@
package filesystem
import (
- "io/ioutil"
"testing"
"github.com/go-git/go-git/v5/plumbing/cache"
"github.com/go-git/go-git/v5/plumbing/storer"
"github.com/go-git/go-git/v5/storage/test"
+ "github.com/go-git/go-billy/v5"
"github.com/go-git/go-billy/v5/memfs"
"github.com/go-git/go-billy/v5/osfs"
+ "github.com/go-git/go-billy/v5/util"
. "gopkg.in/check.v1"
)
@@ -18,13 +19,18 @@ func Test(t *testing.T) { TestingT(t) }
type StorageSuite struct {
test.BaseStorageSuite
dir string
+ fs billy.Filesystem
}
var _ = Suite(&StorageSuite{})
func (s *StorageSuite) SetUpTest(c *C) {
- s.dir = c.MkDir()
- storage := NewStorage(osfs.New(s.dir), cache.NewObjectLRUDefault())
+ tmp, err := util.TempDir(osfs.Default, "", "go-git-filestystem-config")
+ c.Assert(err, IsNil)
+
+ s.dir = tmp
+ s.fs = osfs.New(s.dir)
+ storage := NewStorage(s.fs, cache.NewObjectLRUDefault())
setUpTest(s, c, storage)
}
@@ -49,7 +55,7 @@ func (s *StorageSuite) TestFilesystem(c *C) {
}
func (s *StorageSuite) TestNewStorageShouldNotAddAnyContentsToDir(c *C) {
- fis, err := ioutil.ReadDir(s.dir)
+ fis, err := s.fs.ReadDir("/")
c.Assert(err, IsNil)
c.Assert(fis, HasLen, 0)
}
@@ -61,9 +67,14 @@ type StorageExclusiveSuite struct {
var _ = Suite(&StorageExclusiveSuite{})
func (s *StorageExclusiveSuite) SetUpTest(c *C) {
- s.dir = c.MkDir()
+ tmp, err := util.TempDir(osfs.Default, "", "go-git-filestystem-config")
+ c.Assert(err, IsNil)
+
+ s.dir = tmp
+ s.fs = osfs.New(s.dir)
+
storage := NewStorageWithOptions(
- osfs.New(s.dir),
+ s.fs,
cache.NewObjectLRUDefault(),
Options{ExclusiveAccess: true})