MCPcopy Create free account
hub / github.com/go-git/go-git / TestTree

Method TestTree

repository_test.go:2988–3009  ·  view source on GitHub ↗
(c *C)

Source from the content-addressed store, hash-verified

2986}
2987
2988func (s *RepositorySuite) TestTree(c *C) {
2989 r, _ := Init(memory.NewStorage(), nil)
2990 err := r.clone(context.Background(), &CloneOptions{
2991 URL: s.GetBasicLocalRepositoryURL(),
2992 })
2993 c.Assert(err, IsNil)
2994
2995 invalidHash := plumbing.NewHash("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
2996 tree, err := r.TreeObject(invalidHash)
2997 c.Assert(tree, IsNil)
2998 c.Assert(err, NotNil)
2999
3000 hash := plumbing.NewHash("dbd3641b371024f44d0e469a9c8f5457b0660de1")
3001 tree, err = r.TreeObject(hash)
3002 c.Assert(err, IsNil)
3003
3004 c.Assert(tree.Hash.IsZero(), Equals, false)
3005 c.Assert(tree.Hash, Equals, tree.ID())
3006 c.Assert(tree.Hash, Equals, hash)
3007 c.Assert(tree.Type(), Equals, plumbing.TreeObject)
3008 c.Assert(len(tree.Entries), Not(Equals), 0)
3009}
3010
3011func (s *RepositorySuite) TestTrees(c *C) {
3012 r, _ := Init(memory.NewStorage(), nil)

Callers

nothing calls this directly

Calls 9

NewStorageFunction · 0.92
NewHashFunction · 0.92
InitFunction · 0.85
cloneMethod · 0.80
TreeObjectMethod · 0.80
IsZeroMethod · 0.65
IDMethod · 0.65
TypeMethod · 0.65

Tested by

no test coverage detected