aboutsummaryrefslogtreecommitdiffstats
path: root/storage
diff options
context:
space:
mode:
Diffstat (limited to 'storage')
-rw-r--r--storage/filesystem/dotgit/dotgit_test.go15
-rw-r--r--storage/filesystem/object_test.go8
2 files changed, 20 insertions, 3 deletions
diff --git a/storage/filesystem/dotgit/dotgit_test.go b/storage/filesystem/dotgit/dotgit_test.go
index 50f8e64..308c6b7 100644
--- a/storage/filesystem/dotgit/dotgit_test.go
+++ b/storage/filesystem/dotgit/dotgit_test.go
@@ -474,16 +474,27 @@ func (s *SuiteDotGit) TestObjectPackWithKeepDescriptors(c *C) {
c.Assert(err, IsNil)
c.Assert(filepath.Ext(pack.Name()), Equals, ".pack")
+ // Move to an specific offset
+ pack.Seek(42, os.SEEK_SET)
+
pack2, err := dir.ObjectPack(f.PackfileHash)
c.Assert(err, IsNil)
- c.Assert(pack, Equals, pack2)
+
+ // If the file is the same the offset should be the same
+ offset, err := pack2.Seek(0, os.SEEK_CUR)
+ c.Assert(err, IsNil)
+ c.Assert(offset, Equals, int64(42))
err = dir.Close()
c.Assert(err, IsNil)
pack2, err = dir.ObjectPack(f.PackfileHash)
c.Assert(err, IsNil)
- c.Assert(pack, Not(Equals), pack2)
+
+ // If the file is opened again its offset should be 0
+ offset, err = pack2.Seek(0, os.SEEK_CUR)
+ c.Assert(err, IsNil)
+ c.Assert(offset, Equals, int64(0))
err = pack2.Close()
c.Assert(err, IsNil)
diff --git a/storage/filesystem/object_test.go b/storage/filesystem/object_test.go
index 6feb6ae..4a921a9 100644
--- a/storage/filesystem/object_test.go
+++ b/storage/filesystem/object_test.go
@@ -2,6 +2,7 @@ package filesystem
import (
"io/ioutil"
+ "os"
"testing"
"gopkg.in/src-d/go-git.v4/plumbing"
@@ -66,12 +67,17 @@ func (s *FsSuite) TestGetFromPackfileKeepDescriptors(c *C) {
pack1, err := dg.ObjectPack(packfiles[0])
c.Assert(err, IsNil)
+ pack1.Seek(42, os.SEEK_SET)
+
err = o.Close()
c.Assert(err, IsNil)
pack2, err := dg.ObjectPack(packfiles[0])
c.Assert(err, IsNil)
- c.Assert(pack1, Not(Equals), pack2)
+
+ offset, err := pack2.Seek(0, os.SEEK_CUR)
+ c.Assert(err, IsNil)
+ c.Assert(offset, Equals, int64(0))
err = o.Close()
c.Assert(err, IsNil)