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

Method TestIterEncodedObjects

storage/transactional/object_test.go:87–120  ·  view source on GitHub ↗
(c *C)

Source from the content-addressed store, hash-verified

85}
86
87func (s *ObjectSuite) TestIterEncodedObjects(c *C) {
88 base := memory.NewStorage()
89 temporal := memory.NewStorage()
90
91 os := NewObjectStorage(base, temporal)
92
93 commit := base.NewEncodedObject()
94 commit.SetType(plumbing.CommitObject)
95
96 ch, err := base.SetEncodedObject(commit)
97 c.Assert(ch.IsZero(), Equals, false)
98 c.Assert(err, IsNil)
99
100 tree := base.NewEncodedObject()
101 tree.SetType(plumbing.TreeObject)
102
103 th, err := os.SetEncodedObject(tree)
104 c.Assert(th.IsZero(), Equals, false)
105 c.Assert(err, IsNil)
106
107 iter, err := os.IterEncodedObjects(plumbing.AnyObject)
108 c.Assert(err, IsNil)
109
110 var hashes []plumbing.Hash
111 err = iter.ForEach(func(obj plumbing.EncodedObject) error {
112 hashes = append(hashes, obj.Hash())
113 return nil
114 })
115
116 c.Assert(err, IsNil)
117 c.Assert(hashes, HasLen, 2)
118 c.Assert(hashes[0], Equals, ch)
119 c.Assert(hashes[1], Equals, th)
120}
121
122func (s *ObjectSuite) TestCommit(c *C) {
123 base := memory.NewStorage()

Callers

nothing calls this directly

Calls 10

SetTypeMethod · 0.95
SetEncodedObjectMethod · 0.95
IterEncodedObjectsMethod · 0.95
NewStorageFunction · 0.92
NewObjectStorageFunction · 0.70
NewEncodedObjectMethod · 0.65
SetEncodedObjectMethod · 0.65
IsZeroMethod · 0.65
ForEachMethod · 0.65
HashMethod · 0.65

Tested by

no test coverage detected