MCPcopy
hub / github.com/go-git/go-git / TestDecodeTruncatedExt

Method TestDecodeTruncatedExt

plumbing/format/index/decoder_test.go:282–307  ·  view source on GitHub ↗
(c *C)

Source from the content-addressed store, hash-verified

280}
281
282func (s *IndexSuite) TestDecodeTruncatedExt(c *C) {
283 idx := s.readSimpleIndex(c)
284
285 buf := bytes.NewBuffer(nil)
286 e := NewEncoder(buf)
287
288 err := e.encode(idx, false)
289 c.Assert(err, IsNil)
290
291 _, err = e.w.Write([]byte("TEST"))
292 c.Assert(err, IsNil)
293
294 err = binary.WriteUint32(e.w, uint32(100))
295 c.Assert(err, IsNil)
296
297 _, err = e.w.Write([]byte("truncated"))
298 c.Assert(err, IsNil)
299
300 err = e.encodeFooter()
301 c.Assert(err, IsNil)
302
303 idx = &Index{}
304 d := NewDecoder(buf)
305 err = d.Decode(idx)
306 c.Assert(err, ErrorMatches, io.EOF.Error())
307}
308
309func (s *IndexSuite) TestDecodeInvalidHash(c *C) {
310 idx := s.readSimpleIndex(c)

Callers

nothing calls this directly

Calls 9

readSimpleIndexMethod · 0.95
encodeMethod · 0.95
encodeFooterMethod · 0.95
DecodeMethod · 0.95
WriteUint32Function · 0.92
NewEncoderFunction · 0.70
NewDecoderFunction · 0.70
WriteMethod · 0.45
ErrorMethod · 0.45

Tested by

no test coverage detected