@@ -293,7 +293,7 @@ func (s *ReaderSuite) TestDecodeCRCs(c *C) {
293293 c .Assert (int (sum ), Equals , 78022211966 )
294294}
295295
296- func (s * ReaderSuite ) TestReadObjectAt (c * C ) {
296+ func (s * ReaderSuite ) TestDecodeObjectAt (c * C ) {
297297 f := fixtures .Basic ().One ()
298298 scanner := packfile .NewScanner (f .Packfile ())
299299 d , err := packfile .NewDecoder (scanner , nil )
@@ -311,6 +311,25 @@ func (s *ReaderSuite) TestReadObjectAt(c *C) {
311311 c .Assert (obj .Hash ().String (), Equals , "6ecf0ef2c2dffb796033e5a02219af86ec6584e5" )
312312}
313313
314+ func (s * ReaderSuite ) TestDecodeObjectAtForType (c * C ) {
315+ f := fixtures .Basic ().One ()
316+ scanner := packfile .NewScanner (f .Packfile ())
317+ d , err := packfile .NewDecoderForType (scanner , nil , plumbing .TreeObject )
318+ c .Assert (err , IsNil )
319+
320+ // when the packfile is ref-delta based, the offsets are required
321+ if f .Is ("ref-delta" ) {
322+ d .SetIndex (getIndexFromIdxFile (f .Idx ()))
323+ }
324+
325+ // the objects at reference 186, is a delta, so should be recall,
326+ // without being read before.
327+ obj , err := d .DecodeObjectAt (186 )
328+ c .Assert (err , IsNil )
329+ c .Assert (obj .Type (), Equals , plumbing .CommitObject )
330+ c .Assert (obj .Hash ().String (), Equals , "6ecf0ef2c2dffb796033e5a02219af86ec6584e5" )
331+ }
332+
314333func (s * ReaderSuite ) TestIndex (c * C ) {
315334 f := fixtures .Basic ().One ()
316335 scanner := packfile .NewScanner (f .Packfile ())
0 commit comments