aboutsummaryrefslogtreecommitdiffstats
path: root/formats/packfile/scanner_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'formats/packfile/scanner_test.go')
-rw-r--r--formats/packfile/scanner_test.go23
1 files changed, 23 insertions, 0 deletions
diff --git a/formats/packfile/scanner_test.go b/formats/packfile/scanner_test.go
index d9fe13c..5f80da0 100644
--- a/formats/packfile/scanner_test.go
+++ b/formats/packfile/scanner_test.go
@@ -2,6 +2,7 @@ package packfile
import (
"bytes"
+ "io"
. "gopkg.in/check.v1"
"gopkg.in/src-d/go-git.v4/core"
@@ -91,6 +92,28 @@ func (s *ScannerSuite) TestNextObjectHeaderWithOutReadObject(c *C) {
c.Assert(n, Equals, f.PackfileHash)
}
+func (s *ScannerSuite) TestNextObjectHeaderWithOutReadObjectNonSeekable(c *C) {
+ f := fixtures.Basic().ByTag("ref-delta").One()
+ r := io.MultiReader(f.Packfile())
+ p := NewScanner(r)
+
+ _, objects, err := p.Header()
+ c.Assert(err, IsNil)
+
+ for i := 0; i < int(objects); i++ {
+ h, _ := p.NextObjectHeader()
+ c.Assert(err, IsNil)
+ c.Assert(*h, DeepEquals, expectedHeadersREF[i])
+ }
+
+ err = p.discardObjectIfNeeded()
+ c.Assert(err, IsNil)
+
+ n, err := p.Checksum()
+ c.Assert(err, IsNil)
+ c.Assert(n, Equals, f.PackfileHash)
+}
+
var expectedHeadersOFS = []ObjectHeader{
{Type: core.CommitObject, Offset: 12, Length: 254},
{Type: core.OFSDeltaObject, Offset: 186, Length: 93, OffsetReference: 12},