aboutsummaryrefslogtreecommitdiffstats
path: root/formats/packfile/parser_test.go
diff options
context:
space:
mode:
authorMáximo Cuadros <mcuadros@gmail.com>2016-09-07 02:04:43 +0200
committerMáximo Cuadros <mcuadros@gmail.com>2016-09-07 02:04:43 +0200
commit56adb5be3ad26a0045ea6c6a6d24dafdff15ba1c (patch)
treebd8ecbb6674f01f03f97fb15083bed0a3e8e021d /formats/packfile/parser_test.go
parent98a22e72a808aa0d5dd62339817404fd9e1c4db6 (diff)
downloadgo-git-56adb5be3ad26a0045ea6c6a6d24dafdff15ba1c.tar.gz
format: packfile new interface
Diffstat (limited to 'formats/packfile/parser_test.go')
-rw-r--r--formats/packfile/parser_test.go20
1 files changed, 17 insertions, 3 deletions
diff --git a/formats/packfile/parser_test.go b/formats/packfile/parser_test.go
index a7959a0..0c07daa 100644
--- a/formats/packfile/parser_test.go
+++ b/formats/packfile/parser_test.go
@@ -3,6 +3,7 @@ package packfile
import (
"bytes"
"encoding/base64"
+ "io/ioutil"
. "gopkg.in/check.v1"
"gopkg.in/src-d/go-git.v4/core"
@@ -15,7 +16,7 @@ var _ = Suite(&ScannerSuite{})
func (s *ScannerSuite) TestHeader(c *C) {
data, _ := base64.StdEncoding.DecodeString(packFileWithEmptyObjects)
- p := NewParser(bytes.NewReader(data))
+ p := NewScanner(bytes.NewReader(data))
version, objects, err := p.Header()
c.Assert(err, IsNil)
c.Assert(version, Equals, VersionSupported)
@@ -25,7 +26,8 @@ func (s *ScannerSuite) TestHeader(c *C) {
func (s *ScannerSuite) TestNextObjectHeader(c *C) {
data, _ := base64.StdEncoding.DecodeString(packFileWithEmptyObjects)
- p := NewParser(bytes.NewReader(data))
+ r := bytes.NewReader(data)
+ p := NewScanner(r)
_, objects, err := p.Header()
c.Assert(err, IsNil)
@@ -39,12 +41,17 @@ func (s *ScannerSuite) TestNextObjectHeader(c *C) {
c.Assert(err, IsNil)
c.Assert(n, Equals, h.Length)
}
+
+ n, err := ioutil.ReadAll(r)
+ c.Assert(err, IsNil)
+ c.Assert(n, HasLen, 20)
}
func (s *ScannerSuite) TestNextObjectHeaderWithOutReadObject(c *C) {
data, _ := base64.StdEncoding.DecodeString(packFileWithEmptyObjects)
- p := NewParser(bytes.NewReader(data))
+ r := bytes.NewReader(data)
+ p := NewScanner(r)
_, objects, err := p.Header()
c.Assert(err, IsNil)
@@ -53,6 +60,13 @@ func (s *ScannerSuite) TestNextObjectHeaderWithOutReadObject(c *C) {
c.Assert(err, IsNil)
c.Assert(*h, DeepEquals, expectedHeaders[i])
}
+
+ err = p.discardObjectIfNeeded()
+ c.Assert(err, IsNil)
+
+ n, err := ioutil.ReadAll(r)
+ c.Assert(err, IsNil)
+ c.Assert(n, HasLen, 20)
}
var expectedHeaders = []ObjectHeader{