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

Method TestDecodeInvalidHash

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

Source from the content-addressed store, hash-verified

307}
308
309func (s *IndexSuite) TestDecodeInvalidHash(c *C) {
310 idx := s.readSimpleIndex(c)
311
312 buf := bytes.NewBuffer(nil)
313 e := NewEncoder(buf)
314
315 err := e.encode(idx, false)
316 c.Assert(err, IsNil)
317
318 err = e.encodeRawExtension("TEST", []byte("testdata"))
319 c.Assert(err, IsNil)
320
321 h := hash.New(crypto.SHA1)
322 err = binary.Write(e.w, h.Sum(nil))
323 c.Assert(err, IsNil)
324
325 idx = &Index{}
326 d := NewDecoder(buf)
327 err = d.Decode(idx)
328 c.Assert(err, ErrorMatches, ErrInvalidChecksum.Error())
329}
330
331func TestDecodeV4StripLength(t *testing.T) {
332 t.Parallel()

Callers

nothing calls this directly

Calls 10

readSimpleIndexMethod · 0.95
encodeMethod · 0.95
encodeRawExtensionMethod · 0.95
DecodeMethod · 0.95
NewFunction · 0.92
WriteFunction · 0.92
SumMethod · 0.80
NewEncoderFunction · 0.70
NewDecoderFunction · 0.70
ErrorMethod · 0.45

Tested by

no test coverage detected