Adapt package.Best to take a Versioner interface

This commit is contained in:
Ettore Di Giacinto
2020-04-04 15:33:14 +02:00
parent aaa8d8b7d6
commit 84625be9ac
6 changed files with 19 additions and 24 deletions

View File

@@ -141,7 +141,7 @@ func (s *Solver) getList(db pkg.PackageDatabase, lsp pkg.Packages) (pkg.Packages
if err != nil || len(packages) == 0 {
cp = pp
} else {
cp = packages.Best()
cp = packages.Best(nil)
}
}
ls = append(ls, cp)
@@ -229,7 +229,7 @@ func (s *Solver) Upgrade(checkconflicts bool) (pkg.Packages, PackagesAssertions,
installedcopy.CreatePackage(p)
packages, ok := availableCache[p.GetName()+p.GetCategory()]
if ok && len(packages) != 0 {
best := packages.Best()
best := packages.Best(nil)
if best.GetVersion() != p.GetVersion() {
toUninstall = append(toUninstall, p)
toInstall = append(toInstall, best)
@@ -272,7 +272,7 @@ func (s *Solver) Uninstall(c pkg.Package, checkconflicts bool) (pkg.Packages, er
if err != nil || len(packages) == 0 {
candidate = c
} else {
candidate = packages.Best()
candidate = packages.Best(nil)
}
//Relax search, otherwise we cannot compute solutions for packages not in definitions
// return nil, errors.Wrap(err, "Package not found between installed")

View File

@@ -882,7 +882,7 @@ var _ = Describe("Solver", func() {
Expect(lst).To(ContainElement(a03))
Expect(lst).ToNot(ContainElement(old))
Expect(len(lst)).To(Equal(5))
p := lst.Best()
p := lst.Best(nil)
Expect(p).To(Equal(a03))
})
})