mirror of
https://github.com/aptly-dev/aptly.git
synced 2026-05-05 22:08:27 +00:00
NewSnapshotFromRefList method.
This commit is contained in:
7
debian/snapshot.go
vendored
7
debian/snapshot.go
vendored
@@ -48,6 +48,11 @@ func NewSnapshotFromRepository(name string, repo *RemoteRepo) (*Snapshot, error)
|
||||
|
||||
// NewSnapshotFromPackageList creates snapshot from PackageList
|
||||
func NewSnapshotFromPackageList(name string, sources []*Snapshot, list *PackageList, description string) *Snapshot {
|
||||
return NewSnapshotFromRefList(name, sources, NewPackageRefListFromPackageList(list), description)
|
||||
}
|
||||
|
||||
// NewSnapshotFromRefList creates snapshot from PackageRefList
|
||||
func NewSnapshotFromRefList(name string, sources []*Snapshot, list *PackageRefList, description string) *Snapshot {
|
||||
sourceUUIDs := make([]string, len(sources))
|
||||
for i := range sources {
|
||||
sourceUUIDs[i] = sources[i].UUID
|
||||
@@ -60,7 +65,7 @@ func NewSnapshotFromPackageList(name string, sources []*Snapshot, list *PackageL
|
||||
SourceKind: "snapshot",
|
||||
SourceIDs: sourceUUIDs,
|
||||
Description: description,
|
||||
packageRefs: NewPackageRefListFromPackageList(list),
|
||||
packageRefs: list,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
10
debian/snapshot_test.go
vendored
10
debian/snapshot_test.go
vendored
@@ -42,6 +42,16 @@ func (s *SnapshotSuite) TestNewSnapshotFromPackageList(c *C) {
|
||||
c.Check(snapshot.SourceIDs, DeepEquals, []string{snap.UUID})
|
||||
}
|
||||
|
||||
func (s *SnapshotSuite) TestNewSnapshotFromRefList(c *C) {
|
||||
snap, _ := NewSnapshotFromRepository("snap1", s.repo)
|
||||
|
||||
snapshot := NewSnapshotFromRefList("snap2", []*Snapshot{snap}, s.reflist, "Merged")
|
||||
c.Check(snapshot.Name, Equals, "snap2")
|
||||
c.Check(snapshot.NumPackages(), Equals, 3)
|
||||
c.Check(snapshot.SourceKind, Equals, "snapshot")
|
||||
c.Check(snapshot.SourceIDs, DeepEquals, []string{snap.UUID})
|
||||
}
|
||||
|
||||
func (s *SnapshotSuite) TestKey(c *C) {
|
||||
snapshot, _ := NewSnapshotFromRepository("snap1", s.repo)
|
||||
c.Assert(len(snapshot.Key()), Equals, 37)
|
||||
|
||||
Reference in New Issue
Block a user