Add error handling for ForEach's.

This commit is contained in:
Andrey Smirnov
2013-12-26 16:58:04 +04:00
parent be7a1762ac
commit 218057ea48
9 changed files with 151 additions and 40 deletions
+13 -1
View File
@@ -1,6 +1,7 @@
package debian
import (
"errors"
"github.com/smira/aptly/database"
"github.com/smira/aptly/utils"
. "launchpad.net/gocheck"
@@ -187,8 +188,19 @@ func (s *RemoteRepoCollectionSuite) TestForEach(c *C) {
s.collection.Add(repo)
count := 0
s.collection.ForEach(func(*RemoteRepo) { count++ })
err := s.collection.ForEach(func(*RemoteRepo) error {
count++
return nil
})
c.Assert(count, Equals, 1)
c.Assert(err, IsNil)
e := errors.New("c")
err = s.collection.ForEach(func(*RemoteRepo) error {
return e
})
c.Assert(err, Equals, e)
}
const exampleReleaseFile = `Origin: LP-PPA-agenda-developers-daily