diff options
author | Máximo Cuadros <mcuadros@gmail.com> | 2016-09-09 20:18:08 +0200 |
---|---|---|
committer | Máximo Cuadros <mcuadros@gmail.com> | 2016-09-09 20:18:08 +0200 |
commit | 6fe1b93e96d4384f34f0562f81116ae565c6954d (patch) | |
tree | 408e677b936c4af75d236b98d07ff20b80bdb14f /storage/filesystem/object_test.go | |
parent | 7c0ca21db6741af7735e3be332987e362393fb07 (diff) | |
download | go-git-6fe1b93e96d4384f34f0562f81116ae565c6954d.tar.gz |
storage: filesystem iter implementation
Diffstat (limited to 'storage/filesystem/object_test.go')
-rw-r--r-- | storage/filesystem/object_test.go | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/storage/filesystem/object_test.go b/storage/filesystem/object_test.go index 99266ab..14c77e4 100644 --- a/storage/filesystem/object_test.go +++ b/storage/filesystem/object_test.go @@ -53,3 +53,41 @@ func (s *FsSuite) TestGetFromPackfileMultiplePackfiles(c *C) { c.Assert(err, IsNil) c.Assert(obj.Hash(), Equals, expected) } + +func (s *FsSuite) TestIter(c *C) { + fixtures.ByTag(".git").Test(c, func(f *fixtures.Fixture) { + fs := f.DotGit() + o, err := newObjectStorage(dotgit.New(fs)) + c.Assert(err, IsNil) + + iter, err := o.Iter(core.AnyObject) + c.Assert(err, IsNil) + + var count int32 + err = iter.ForEach(func(o core.Object) error { + count++ + return nil + }) + + c.Assert(err, IsNil) + c.Assert(count, Equals, f.ObjectsCount) + }) +} + +func (s *FsSuite) TestIterWithType(c *C) { + fixtures.ByTag(".git").Test(c, func(f *fixtures.Fixture) { + fs := f.DotGit() + o, err := newObjectStorage(dotgit.New(fs)) + c.Assert(err, IsNil) + + iter, err := o.Iter(core.CommitObject) + c.Assert(err, IsNil) + + err = iter.ForEach(func(o core.Object) error { + c.Assert(o.Type(), Equals, core.CommitObject) + return nil + }) + + c.Assert(err, IsNil) + }) +} |