mirror of
https://github.com/aptly-dev/aptly.git
synced 2026-05-07 22:20:24 +00:00
RemoteRepo by UUID lookup.
This commit is contained in:
Vendored
+10
@@ -320,6 +320,16 @@ func (collection *RemoteRepoCollection) ByName(name string) (*RemoteRepo, error)
|
|||||||
return nil, fmt.Errorf("mirror with name %s not found", name)
|
return nil, fmt.Errorf("mirror with name %s not found", name)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ByUUID looks up repository by uuid
|
||||||
|
func (collection *RemoteRepoCollection) ByUUID(uuid string) (*RemoteRepo, error) {
|
||||||
|
for _, r := range collection.list {
|
||||||
|
if r.UUID == uuid {
|
||||||
|
return r, nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return nil, fmt.Errorf("mirror with uuid %s not found", uuid)
|
||||||
|
}
|
||||||
|
|
||||||
// ForEach runs method for each repository
|
// ForEach runs method for each repository
|
||||||
func (collection *RemoteRepoCollection) ForEach(handler func(*RemoteRepo)) {
|
func (collection *RemoteRepoCollection) ForEach(handler func(*RemoteRepo)) {
|
||||||
for _, r := range collection.list {
|
for _, r := range collection.list {
|
||||||
|
|||||||
Vendored
+11
@@ -147,7 +147,18 @@ func (s *RemoteRepoCollectionSuite) TestAddByName(c *C) {
|
|||||||
r, err = collection.ByName("yandex")
|
r, err = collection.ByName("yandex")
|
||||||
c.Assert(err, IsNil)
|
c.Assert(err, IsNil)
|
||||||
c.Assert(r.String(), Equals, repo.String())
|
c.Assert(r.String(), Equals, repo.String())
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *RemoteRepoCollectionSuite) TestByUUID(c *C) {
|
||||||
|
r, err := s.collection.ByUUID("some-uuid")
|
||||||
|
c.Assert(err, ErrorMatches, "*.not found")
|
||||||
|
|
||||||
|
repo, _ := NewRemoteRepo("yandex", "http://mirror.yandex.ru/debian/", "squeeze", []string{"main"}, []string{})
|
||||||
|
c.Assert(s.collection.Add(repo), IsNil)
|
||||||
|
|
||||||
|
r, err = s.collection.ByUUID(repo.UUID)
|
||||||
|
c.Assert(err, IsNil)
|
||||||
|
c.Assert(r.String(), Equals, repo.String())
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *RemoteRepoCollectionSuite) TestUpdateLoadComplete(c *C) {
|
func (s *RemoteRepoCollectionSuite) TestUpdateLoadComplete(c *C) {
|
||||||
|
|||||||
Reference in New Issue
Block a user