A bit of niceness: more hints for first-time user.

This commit is contained in:
Andrey Smirnov
2014-01-10 13:21:37 +04:00
parent 356187f3ae
commit 01338d6037
6 changed files with 40 additions and 16 deletions

5
debian/remote.go vendored
View File

@@ -358,3 +358,8 @@ func (collection *RemoteRepoCollection) ForEach(handler func(*RemoteRepo) error)
}
return err
}
// Len returns number of remote repos
func (collection *RemoteRepoCollection) Len() int {
return len(collection.list)
}

View File

@@ -219,7 +219,7 @@ func (s *RemoteRepoCollectionSuite) TestUpdateLoadComplete(c *C) {
c.Assert(r.NumPackages(), Equals, 3)
}
func (s *RemoteRepoCollectionSuite) TestForEach(c *C) {
func (s *RemoteRepoCollectionSuite) TestForEachAndLen(c *C) {
repo, _ := NewRemoteRepo("yandex", "http://mirror.yandex.ru/debian/", "squeeze", []string{"main"}, []string{})
s.collection.Add(repo)
@@ -231,6 +231,8 @@ func (s *RemoteRepoCollectionSuite) TestForEach(c *C) {
c.Assert(count, Equals, 1)
c.Assert(err, IsNil)
c.Check(s.collection.Len(), Equals, 1)
e := errors.New("c")
err = s.collection.ForEach(func(*RemoteRepo) error {

6
debian/snapshot.go vendored
View File

@@ -172,3 +172,9 @@ func (collection *SnapshotCollection) ForEach(handler func(*Snapshot) error) err
}
return err
}
// Len returns number of snapshots in collection
// ForEach runs method for each snapshot
func (collection *SnapshotCollection) Len() int {
return len(collection.list)
}

View File

@@ -112,7 +112,7 @@ func (s *SnapshotCollectionSuite) TestUpdateLoadComplete(c *C) {
c.Assert(snapshot.NumPackages(), Equals, 3)
}
func (s *SnapshotCollectionSuite) TestForEach(c *C) {
func (s *SnapshotCollectionSuite) TestForEachAndLen(c *C) {
s.collection.Add(s.snapshot1)
s.collection.Add(s.snapshot2)
@@ -124,6 +124,8 @@ func (s *SnapshotCollectionSuite) TestForEach(c *C) {
c.Assert(count, Equals, 2)
c.Assert(err, IsNil)
c.Check(s.collection.Len(), Equals, 2)
e := errors.New("d")
err = s.collection.ForEach(func(*Snapshot) error {
return e