aboutsummaryrefslogtreecommitdiffstats
path: root/storage/test/storage_suite.go
diff options
context:
space:
mode:
authorMáximo Cuadros <mcuadros@gmail.com>2017-07-27 18:04:00 +0200
committerGitHub <noreply@github.com>2017-07-27 18:04:00 +0200
commit86f33ed017b55898758bf8900a085f355b2793d0 (patch)
tree1e741bed0672a7afb62cda37ca0b1d86fad52889 /storage/test/storage_suite.go
parent7b08a3005480a50f0f4290aff8f3702085d5e30d (diff)
parent16b24f84e9342234ad90da27a6532887b05d1965 (diff)
downloadgo-git-86f33ed017b55898758bf8900a085f355b2793d0.tar.gz
Merge pull request #515 from smola/reuse-packed-objects
storage: reuse deltas from packfiles
Diffstat (limited to 'storage/test/storage_suite.go')
-rw-r--r--storage/test/storage_suite.go34
1 files changed, 34 insertions, 0 deletions
diff --git a/storage/test/storage_suite.go b/storage/test/storage_suite.go
index 7cb0fe3..624dc57 100644
--- a/storage/test/storage_suite.go
+++ b/storage/test/storage_suite.go
@@ -403,6 +403,40 @@ func (s *BaseStorageSuite) TestModule(c *C) {
c.Assert(storer, NotNil)
}
+func (s *BaseStorageSuite) TestDeltaObjectStorer(c *C) {
+ dos, ok := s.Storer.(storer.DeltaObjectStorer)
+ if !ok {
+ c.Skip("not an DeltaObjectStorer")
+ }
+
+ pwr, ok := s.Storer.(storer.PackfileWriter)
+ if !ok {
+ c.Skip("not a storer.PackWriter")
+ }
+
+ pw, err := pwr.PackfileWriter()
+ c.Assert(err, IsNil)
+
+ f := fixtures.Basic().One()
+ _, err = io.Copy(pw, f.Packfile())
+ c.Assert(err, IsNil)
+
+ err = pw.Close()
+ c.Assert(err, IsNil)
+
+ h := plumbing.NewHash("32858aad3c383ed1ff0a0f9bdf231d54a00c9e88")
+ obj, err := dos.DeltaObject(plumbing.AnyObject, h)
+ c.Assert(err, IsNil)
+ c.Assert(obj.Type(), Equals, plumbing.BlobObject)
+
+ h = plumbing.NewHash("aa9b383c260e1d05fbbf6b30a02914555e20c725")
+ obj, err = dos.DeltaObject(plumbing.AnyObject, h)
+ c.Assert(err, IsNil)
+ c.Assert(obj.Type(), Equals, plumbing.OFSDeltaObject)
+ _, ok = obj.(plumbing.DeltaObject)
+ c.Assert(ok, Equals, true)
+}
+
func objectEquals(a plumbing.EncodedObject, b plumbing.EncodedObject) error {
ha := a.Hash()
hb := b.Hash()