(c *C)
| 105 | } |
| 106 | |
| 107 | func (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 | |
| 150 | func (s *BaseStorageSuite) TestPackfileWriter(c *C) { |
| 151 | pwr, ok := s.Storer.(storer.PackfileWriter) |
nothing calls this directly
no test coverage detected