aboutsummaryrefslogtreecommitdiffstats
path: root/formats/packfile/scanner_test.go
diff options
context:
space:
mode:
authorMáximo Cuadros <mcuadros@gmail.com>2016-09-24 19:24:37 +0200
committerMáximo Cuadros <mcuadros@gmail.com>2016-09-24 19:24:37 +0200
commit859775d320d574979c63a114de1437e3c5d9114c (patch)
treea6b48a64e86132592b76edbcf586ed0cc5827ee1 /formats/packfile/scanner_test.go
parentb53b9073688df6cfc1698eef163ef4cc50a15758 (diff)
downloadgo-git-859775d320d574979c63a114de1437e3c5d9114c.tar.gz
formats: packfile improving test coverage
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},