diff options
author | Máximo Cuadros <mcuadros@gmail.com> | 2016-09-07 02:04:43 +0200 |
---|---|---|
committer | Máximo Cuadros <mcuadros@gmail.com> | 2016-09-07 02:04:43 +0200 |
commit | 56adb5be3ad26a0045ea6c6a6d24dafdff15ba1c (patch) | |
tree | bd8ecbb6674f01f03f97fb15083bed0a3e8e021d /formats/packfile/decoder_test.go | |
parent | 98a22e72a808aa0d5dd62339817404fd9e1c4db6 (diff) | |
download | go-git-56adb5be3ad26a0045ea6c6a6d24dafdff15ba1c.tar.gz |
format: packfile new interface
Diffstat (limited to 'formats/packfile/decoder_test.go')
-rw-r--r-- | formats/packfile/decoder_test.go | 36 |
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{ |