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

Method TestTreeDecodeEncodeIdempotent

plumbing/object/tree_test.go:253–275  ·  view source on GitHub ↗
(c *C)

Source from the content-addressed store, hash-verified

251}
252
253func (s *TreeSuite) TestTreeDecodeEncodeIdempotent(c *C) {
254 trees := []*Tree{
255 {
256 Entries: []TreeEntry{
257 {"foo", filemode.Regular, plumbing.NewHash("b029517f6300c2da0f4b651b8642506cd6aaf45d")},
258 {"bar", filemode.Regular, plumbing.NewHash("c029517f6300c2da0f4b651b8642506cd6aaf45d")},
259 {"baz", filemode.Regular, plumbing.NewHash("d029517f6300c2da0f4b651b8642506cd6aaf45d")},
260 },
261 },
262 }
263 for _, tree := range trees {
264 sort.Sort(TreeEntrySorter(tree.Entries))
265 obj := &plumbing.MemoryObject{}
266 err := tree.Encode(obj)
267 c.Assert(err, IsNil)
268 newTree := &Tree{}
269 err = newTree.Decode(obj)
270 c.Assert(err, IsNil)
271 tree.Hash = obj.Hash()
272 c.Assert(newTree.Hash, Equals, tree.Hash)
273 c.Assert(newTree.Entries, DeepEquals, tree.Entries)
274 }
275}
276
277func (s *TreeSuite) TestTreeDiff(c *C) {
278 f := fixtures.ByURL("https://github.com/src-d/go-git.git").One()

Callers

nothing calls this directly

Calls 5

DecodeMethod · 0.95
HashMethod · 0.95
NewHashFunction · 0.92
TreeEntrySorterTypeAlias · 0.85
EncodeMethod · 0.65

Tested by

no test coverage detected