MCPcopy Index your code
hub / github.com/go-git/go-git / TestHashesWithPrefix

Method TestHashesWithPrefix

storage/filesystem/object_test.go:424–438  ·  view source on GitHub ↗
(c *C)

Source from the content-addressed store, hash-verified

422}
423
424func (s *FsSuite) TestHashesWithPrefix(c *C) {
425 // Same setup as TestGetFromObjectFile.
426 fs := fixtures.ByTag(".git").ByTag("unpacked").One().DotGit()
427 o := NewObjectStorage(dotgit.New(fs), cache.NewObjectLRUDefault())
428 expected := plumbing.NewHash("f3dfe29d268303fc6e1bbce268605fc99573406e")
429 obj, err := o.EncodedObject(plumbing.AnyObject, expected)
430 c.Assert(err, IsNil)
431 c.Assert(obj.Hash(), Equals, expected)
432
433 prefix, _ := hex.DecodeString("f3dfe2")
434 hashes, err := o.HashesWithPrefix(prefix)
435 c.Assert(err, IsNil)
436 c.Assert(hashes, HasLen, 1)
437 c.Assert(hashes[0].String(), Equals, "f3dfe29d268303fc6e1bbce268605fc99573406e")
438}
439
440func (s *FsSuite) TestHashesWithPrefixFromPackfile(c *C) {
441 // Same setup as TestGetFromPackfile

Callers

nothing calls this directly

Calls 8

EncodedObjectMethod · 0.95
HashesWithPrefixMethod · 0.95
NewFunction · 0.92
NewObjectLRUDefaultFunction · 0.92
NewHashFunction · 0.92
NewObjectStorageFunction · 0.70
HashMethod · 0.65
StringMethod · 0.65

Tested by

no test coverage detected