(c *C)
| 227 | } |
| 228 | |
| 229 | func (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 | |
| 253 | func (s *TreeSuite) TestTreeDecodeEncodeIdempotent(c *C) { |
| 254 | trees := []*Tree{ |
nothing calls this directly
no test coverage detected