aboutsummaryrefslogtreecommitdiffstats
path: root/formats/packfile/decoder_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'formats/packfile/decoder_test.go')
-rw-r--r--formats/packfile/decoder_test.go36
1 files changed, 27 insertions, 9 deletions
diff --git a/formats/packfile/decoder_test.go b/formats/packfile/decoder_test.go
index 5a95af1..e229f50 100644
--- a/formats/packfile/decoder_test.go
+++ b/formats/packfile/decoder_test.go
@@ -24,9 +24,9 @@ func (s *ReaderSuite) TestReadPackfile(c *C) {
data, _ := base64.StdEncoding.DecodeString(packFileWithEmptyObjects)
f := bytes.NewReader(data)
sto := memory.NewStorage()
- d := NewDecoder(sto.ObjectStorage(), NewParser(f), nil)
+ d := NewDecoder(NewScanner(f), sto.ObjectStorage())
- err := d.Decode()
+ _, err := d.Decode()
c.Assert(err, IsNil)
AssertObjects(c, sto, []string{
@@ -44,21 +44,39 @@ func (s *ReaderSuite) TestReadPackfile(c *C) {
})
}
-func (s *ReaderSuite) TestReadPackfileOFSDelta(c *C) {
- s.testReadPackfileGitFixture(c, "fixtures/git-fixture.ofs-delta", OFSDeltaFormat)
+func (s *ReaderSuite) TestDecodeOFSDelta(c *C) {
+ s.testDecode(c, "fixtures/git-fixture.ofs-delta", true)
+}
+func (s *ReaderSuite) TestDecodeOFSDeltaNoSeekable(c *C) {
+ s.testDecode(c, "fixtures/git-fixture.ofs-delta", false)
}
-func (s *ReaderSuite) TestReadPackfileREFDelta(c *C) {
- s.testReadPackfileGitFixture(c, "fixtures/git-fixture.ref-delta", REFDeltaFormat)
+
+func (s *ReaderSuite) TestDecodeREFDelta(c *C) {
+ s.testDecode(c, "fixtures/git-fixture.ref-delta", true)
}
-func (s *ReaderSuite) testReadPackfileGitFixture(c *C, file string, format Format) {
+func (s *ReaderSuite) TestDecodeREFDeltaNoSeekable(c *C) {
+ s.testDecode(c, "fixtures/git-fixture.ref-delta", false)
+}
+
+func (s *ReaderSuite) testDecode(c *C, file string, seekable bool) {
f, err := os.Open(file)
c.Assert(err, IsNil)
+
+ scanner := NewScanner(f)
+ if !seekable {
+ scanner = NewScannerFromReader(f)
+ }
+
+ s.doTestDecodeWithScanner(c, scanner)
+}
+
+func (s *ReaderSuite) doTestDecodeWithScanner(c *C, scanner *Scanner) {
sto := memory.NewStorage()
- d := NewDecoder(sto.ObjectStorage(), NewParser(f), f)
+ d := NewDecoder(scanner, sto.ObjectStorage())
- err = d.Decode()
+ _, err := d.Decode()
c.Assert(err, IsNil)
AssertObjects(c, sto, []string{