mirror of
https://github.com/aptly-dev/aptly.git
synced 2026-06-04 05:10:40 +00:00
Creating snapshots from local repos.
This commit is contained in:
Vendored
+17
@@ -47,6 +47,23 @@ func NewSnapshotFromRepository(name string, repo *RemoteRepo) (*Snapshot, error)
|
|||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// NewSnapshotFromLocalRepo creates snapshot from current state of local repository
|
||||||
|
func NewSnapshotFromLocalRepo(name string, repo *LocalRepo) (*Snapshot, error) {
|
||||||
|
if repo.packageRefs == nil {
|
||||||
|
return nil, errors.New("local repo doesn't have packages")
|
||||||
|
}
|
||||||
|
|
||||||
|
return &Snapshot{
|
||||||
|
UUID: uuid.New(),
|
||||||
|
Name: name,
|
||||||
|
CreatedAt: time.Now(),
|
||||||
|
SourceKind: "local",
|
||||||
|
SourceIDs: []string{repo.UUID},
|
||||||
|
Description: fmt.Sprintf("Snapshot from local repo %s", repo),
|
||||||
|
packageRefs: repo.packageRefs,
|
||||||
|
}, nil
|
||||||
|
}
|
||||||
|
|
||||||
// NewSnapshotFromPackageList creates snapshot from PackageList
|
// NewSnapshotFromPackageList creates snapshot from PackageList
|
||||||
func NewSnapshotFromPackageList(name string, sources []*Snapshot, list *PackageList, description string) *Snapshot {
|
func NewSnapshotFromPackageList(name string, sources []*Snapshot, list *PackageList, description string) *Snapshot {
|
||||||
return NewSnapshotFromRefList(name, sources, NewPackageRefListFromPackageList(list), description)
|
return NewSnapshotFromRefList(name, sources, NewPackageRefListFromPackageList(list), description)
|
||||||
|
|||||||
Vendored
+16
@@ -32,6 +32,22 @@ func (s *SnapshotSuite) TestNewSnapshotFromRepository(c *C) {
|
|||||||
c.Check(err, ErrorMatches, ".*not updated")
|
c.Check(err, ErrorMatches, ".*not updated")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (s *SnapshotSuite) TestNewSnapshotFromLocalRepo(c *C) {
|
||||||
|
localRepo := NewLocalRepo("lala", "hoorah!")
|
||||||
|
|
||||||
|
_, err := NewSnapshotFromLocalRepo("snap2", localRepo)
|
||||||
|
c.Check(err, ErrorMatches, "local repo doesn't have packages")
|
||||||
|
|
||||||
|
localRepo.UpdateRefList(s.reflist)
|
||||||
|
snapshot, _ := NewSnapshotFromLocalRepo("snap1", localRepo)
|
||||||
|
c.Check(snapshot.Name, Equals, "snap1")
|
||||||
|
c.Check(snapshot.NumPackages(), Equals, 3)
|
||||||
|
c.Check(snapshot.RefList().Len(), Equals, 3)
|
||||||
|
c.Check(snapshot.SourceKind, Equals, "local")
|
||||||
|
c.Check(snapshot.SourceIDs, DeepEquals, []string{localRepo.UUID})
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
func (s *SnapshotSuite) TestNewSnapshotFromPackageList(c *C) {
|
func (s *SnapshotSuite) TestNewSnapshotFromPackageList(c *C) {
|
||||||
snap, _ := NewSnapshotFromRepository("snap1", s.repo)
|
snap, _ := NewSnapshotFromRepository("snap1", s.repo)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user