aboutsummaryrefslogtreecommitdiffstats
path: root/plumbing/format/packfile/scanner_test.go
diff options
context:
space:
mode:
authorFilip Navara <filip.navara@gmail.com>2018-11-28 01:29:41 +0100
committerMáximo Cuadros <mcuadros@gmail.com>2018-11-28 01:29:41 +0100
commit8f52c5099e7fe4a2519920a7bbf5a9bb52ff9cec (patch)
tree6b08348c45ad42e1979d35b43908d5077d99cf78 /plumbing/format/packfile/scanner_test.go
parent3dbfb89e0f5bce0008724e547b999fe3af9f60db (diff)
downloadgo-git-8f52c5099e7fe4a2519920a7bbf5a9bb52ff9cec.tar.gz
plumbing: format/packfile, performance optimizations for reading large commit histories (#963)
Signed-off-by: Filip Navara <navara@emclient.com>
Diffstat (limited to 'plumbing/format/packfile/scanner_test.go')
-rw-r--r--plumbing/format/packfile/scanner_test.go17
1 files changed, 17 insertions, 0 deletions
diff --git a/plumbing/format/packfile/scanner_test.go b/plumbing/format/packfile/scanner_test.go
index 644d0eb..091b457 100644
--- a/plumbing/format/packfile/scanner_test.go
+++ b/plumbing/format/packfile/scanner_test.go
@@ -118,6 +118,23 @@ func (s *ScannerSuite) TestNextObjectHeaderWithOutReadObjectNonSeekable(c *C) {
c.Assert(n, Equals, f.PackfileHash)
}
+func (s *ScannerSuite) TestSeekObjectHeader(c *C) {
+ r := fixtures.Basic().One().Packfile()
+ p := NewScanner(r)
+
+ h, err := p.SeekObjectHeader(expectedHeadersOFS[4].Offset)
+ c.Assert(err, IsNil)
+ c.Assert(h, DeepEquals, &expectedHeadersOFS[4])
+}
+
+func (s *ScannerSuite) TestSeekObjectHeaderNonSeekable(c *C) {
+ r := io.MultiReader(fixtures.Basic().One().Packfile())
+ p := NewScanner(r)
+
+ _, err := p.SeekObjectHeader(expectedHeadersOFS[4].Offset)
+ c.Assert(err, Equals, ErrSeekNotSupported)
+}
+
var expectedHeadersOFS = []ObjectHeader{
{Type: plumbing.CommitObject, Offset: 12, Length: 254},
{Type: plumbing.OFSDeltaObject, Offset: 186, Length: 93, OffsetReference: 12},