aboutsummaryrefslogtreecommitdiffstats
path: root/storage/filesystem
diff options
context:
space:
mode:
authorSantiago M. Mola <santi@mola.io>2017-07-18 10:39:36 +0200
committerSantiago M. Mola <santi@mola.io>2017-07-19 14:48:42 +0200
commitebc25df06ce7d11afe88339af7bb097926599b7d (patch)
tree8700fa368f5f555656e5d61a41d4be72c6fced25 /storage/filesystem
parentf2e4b4d0b73f9ae1a53adc4479991bf651dfb99a (diff)
downloadgo-git-ebc25df06ce7d11afe88339af7bb097926599b7d.tar.gz
test: add more PackfileWriter tests
Diffstat (limited to 'storage/filesystem')
-rw-r--r--storage/filesystem/internal/dotgit/writers_test.go28
-rw-r--r--storage/filesystem/storage_test.go1
2 files changed, 27 insertions, 2 deletions
diff --git a/storage/filesystem/internal/dotgit/writers_test.go b/storage/filesystem/internal/dotgit/writers_test.go
index d2c7b6f..1342396 100644
--- a/storage/filesystem/internal/dotgit/writers_test.go
+++ b/storage/filesystem/internal/dotgit/writers_test.go
@@ -12,6 +12,7 @@ import (
. "gopkg.in/check.v1"
"gopkg.in/src-d/go-billy.v3/osfs"
+ "gopkg.in/src-d/go-git.v4/plumbing/format/packfile"
)
func (s *SuiteDotGit) TestNewObjectPack(c *C) {
@@ -35,13 +36,30 @@ func (s *SuiteDotGit) TestNewObjectPack(c *C) {
c.Assert(w.Close(), IsNil)
- stat, err := fs.Stat(fmt.Sprintf("objects/pack/pack-%s.pack", f.PackfileHash))
+ pfPath := fmt.Sprintf("objects/pack/pack-%s.pack", f.PackfileHash)
+ idxPath := fmt.Sprintf("objects/pack/pack-%s.idx", f.PackfileHash)
+
+ stat, err := fs.Stat(pfPath)
c.Assert(err, IsNil)
c.Assert(stat.Size(), Equals, int64(84794))
- stat, err = fs.Stat(fmt.Sprintf("objects/pack/pack-%s.idx", f.PackfileHash))
+ stat, err = fs.Stat(idxPath)
c.Assert(err, IsNil)
c.Assert(stat.Size(), Equals, int64(1940))
+
+ pf, err := fs.Open(pfPath)
+ c.Assert(err, IsNil)
+ pfs := packfile.NewScanner(pf)
+ _, objects, err := pfs.Header()
+ c.Assert(err, IsNil)
+ for i := uint32(0); i < objects; i++ {
+ _, err := pfs.NextObjectHeader()
+ if err != nil {
+ c.Assert(err, IsNil)
+ break
+ }
+ }
+ c.Assert(pfs.Close(), IsNil)
}
func (s *SuiteDotGit) TestNewObjectPackUnused(c *C) {
@@ -63,6 +81,12 @@ func (s *SuiteDotGit) TestNewObjectPackUnused(c *C) {
info, err := fs.ReadDir("objects/pack")
c.Assert(err, IsNil)
c.Assert(info, HasLen, 0)
+
+ // check clean up of temporary files
+ info, err = fs.ReadDir("")
+ for _, fi := range info {
+ c.Assert(fi.IsDir(), Equals, true)
+ }
}
func (s *SuiteDotGit) TestSyncedReader(c *C) {
diff --git a/storage/filesystem/storage_test.go b/storage/filesystem/storage_test.go
index 2ced9dd..22709f5 100644
--- a/storage/filesystem/storage_test.go
+++ b/storage/filesystem/storage_test.go
@@ -26,6 +26,7 @@ func (s *StorageSuite) SetUpTest(c *C) {
c.Assert(err, IsNil)
s.BaseStorageSuite = test.NewBaseStorageSuite(storage)
+ s.BaseStorageSuite.SetUpTest(c)
}
func (s *StorageSuite) TestFilesystem(c *C) {