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

Method TestTreeEntriesSorted

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

Source from the content-addressed store, hash-verified

227}
228
229func (s *TreeSuite) TestTreeEntriesSorted(c *C) {
230 tree := &Tree{
231 Entries: []TreeEntry{
232 {"foo", filemode.Regular, plumbing.NewHash("b029517f6300c2da0f4b651b8642506cd6aaf45d")},
233 {"bar", filemode.Regular, plumbing.NewHash("c029517f6300c2da0f4b651b8642506cd6aaf45d")},
234 {"baz", filemode.Regular, plumbing.NewHash("d029517f6300c2da0f4b651b8642506cd6aaf45d")},
235 },
236 }
237
238 {
239 c.Assert(sort.IsSorted(TreeEntrySorter(tree.Entries)), Equals, false)
240 obj := &plumbing.MemoryObject{}
241 err := tree.Encode(obj)
242 c.Assert(err, Equals, ErrEntriesNotSorted)
243 }
244
245 {
246 sort.Sort(TreeEntrySorter(tree.Entries))
247 obj := &plumbing.MemoryObject{}
248 err := tree.Encode(obj)
249 c.Assert(err, IsNil)
250 }
251}
252
253func (s *TreeSuite) TestTreeDecodeEncodeIdempotent(c *C) {
254 trees := []*Tree{

Callers

nothing calls this directly

Calls 3

EncodeMethod · 0.95
NewHashFunction · 0.92
TreeEntrySorterTypeAlias · 0.85

Tested by

no test coverage detected