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

Method TestIterEncodedObjects

storage/test/storage_suite.go:107–148  ·  view source on GitHub ↗
(c *C)

Source from the content-addressed store, hash-verified

105}
106
107func (s *BaseStorageSuite) TestIterEncodedObjects(c *C) {
108 for _, o := range s.testObjects {
109 h, err := s.Storer.SetEncodedObject(o.Object)
110 c.Assert(err, IsNil)
111 c.Assert(h, Equals, o.Object.Hash())
112 }
113
114 for _, t := range s.validTypes {
115 comment := Commentf("failed for type %s)", t.String())
116 i, err := s.Storer.IterEncodedObjects(t)
117 c.Assert(err, IsNil, comment)
118
119 o, err := i.Next()
120 c.Assert(err, IsNil)
121 c.Assert(objectEquals(o, s.testObjects[t].Object), IsNil)
122
123 o, err = i.Next()
124 c.Assert(o, IsNil)
125 c.Assert(err, Equals, io.EOF, comment)
126 }
127
128 i, err := s.Storer.IterEncodedObjects(plumbing.AnyObject)
129 c.Assert(err, IsNil)
130
131 foundObjects := []plumbing.EncodedObject{}
132 i.ForEach(func(o plumbing.EncodedObject) error {
133 foundObjects = append(foundObjects, o)
134 return nil
135 })
136
137 c.Assert(foundObjects, HasLen, len(s.testObjects))
138 for _, to := range s.testObjects {
139 found := false
140 for _, o := range foundObjects {
141 if to.Object.Hash() == o.Hash() {
142 found = true
143 break
144 }
145 }
146 c.Assert(found, Equals, true, Commentf("Object of type %s not found", to.Type.String()))
147 }
148}
149
150func (s *BaseStorageSuite) TestPackfileWriter(c *C) {
151 pwr, ok := s.Storer.(storer.PackfileWriter)

Callers

nothing calls this directly

Calls 7

objectEqualsFunction · 0.85
SetEncodedObjectMethod · 0.65
HashMethod · 0.65
StringMethod · 0.65
IterEncodedObjectsMethod · 0.65
NextMethod · 0.65
ForEachMethod · 0.65

Tested by

no test coverage detected