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

Method TestTree

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

Source from the content-addressed store, hash-verified

2952}
2953
2954func (s *RepositorySuite) TestTree(c *C) {
2955 r, _ := Init(memory.NewStorage(), nil)
2956 err := r.clone(context.Background(), &CloneOptions{
2957 URL: s.GetBasicLocalRepositoryURL(),
2958 })
2959 c.Assert(err, IsNil)
2960
2961 invalidHash := plumbing.NewHash("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
2962 tree, err := r.TreeObject(invalidHash)
2963 c.Assert(tree, IsNil)
2964 c.Assert(err, NotNil)
2965
2966 hash := plumbing.NewHash("dbd3641b371024f44d0e469a9c8f5457b0660de1")
2967 tree, err = r.TreeObject(hash)
2968 c.Assert(err, IsNil)
2969
2970 c.Assert(tree.Hash.IsZero(), Equals, false)
2971 c.Assert(tree.Hash, Equals, tree.ID())
2972 c.Assert(tree.Hash, Equals, hash)
2973 c.Assert(tree.Type(), Equals, plumbing.TreeObject)
2974 c.Assert(len(tree.Entries), Not(Equals), 0)
2975}
2976
2977func (s *RepositorySuite) TestTrees(c *C) {
2978 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