diff options
author | Máximo Cuadros <mcuadros@gmail.com> | 2021-05-02 23:40:08 +0200 |
---|---|---|
committer | Máximo Cuadros <mcuadros@gmail.com> | 2021-05-02 23:40:08 +0200 |
commit | 01df7536992af375a54bbedf45369a475953e372 (patch) | |
tree | 8435050f4388f15b3a85d135a3f7d11b1ff61540 /storage/filesystem/storage_test.go | |
parent | 67af9d7223b0cc643025d958c592291f7475ac75 (diff) | |
download | go-git-01df7536992af375a54bbedf45369a475953e372.tar.gz |
*: use go-billy instead of os calls
Diffstat (limited to 'storage/filesystem/storage_test.go')
-rw-r--r-- | storage/filesystem/storage_test.go | 23 |
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}) |