Stabilize tests after changes

With BuildWorld() we get more results back (now we return the whole
model, including the false assertions).

Besides, now solving with BuildWorld() detects an invalid case:
when we supply a provided, the definitionDB shouldn't explictly supply
also the package that has to be provided. This would cause to 'shadow'
packages between repositories.

The test was invalid before, and shouldn't have contained A1. Moved the
test to Pending to inspect it further in subsequent dev iterations
This commit is contained in:
Ettore Di Giacinto
2021-01-11 23:35:18 +01:00
parent 186fa58ab0
commit 40fc948c6e
4 changed files with 39 additions and 12 deletions

View File

@@ -111,7 +111,7 @@ var _ = Describe("Parallel", func() {
Expect(solution).ToNot(ContainElement(PackageAssert{Package: B, Value: true}))
Expect(solution).ToNot(ContainElement(PackageAssert{Package: D, Value: true}))
Expect(len(solution)).To(Equal(3))
Expect(len(solution)).To(Equal(5))
})
It("Solves correctly if the selected package to install has requirements", func() {

View File

@@ -79,7 +79,7 @@ var _ = Describe("Resolver", func() {
solution, err := s.Install([]pkg.Package{D, F}) // D and F should go as they have no deps. A/E should be filtered by QLearn
Expect(err).ToNot(HaveOccurred())
Expect(len(solution)).To(Equal(3))
Expect(len(solution)).To(Equal(6))
Expect(solution).ToNot(ContainElement(PackageAssert{Package: A, Value: true}))
Expect(solution).ToNot(ContainElement(PackageAssert{Package: B, Value: true}))
@@ -117,7 +117,7 @@ var _ = Describe("Resolver", func() {
Expect(solution).To(ContainElement(PackageAssert{Package: C, Value: true}))
Expect(solution).To(ContainElement(PackageAssert{Package: D, Value: true}))
Expect(len(solution)).To(Equal(2))
Expect(len(solution)).To(Equal(4))
})
It("will find out that we can install D and F by ignoring E and A", func() {
@@ -148,8 +148,7 @@ var _ = Describe("Resolver", func() {
Expect(solution).To(ContainElement(PackageAssert{Package: D, Value: true}))
Expect(solution).ToNot(ContainElement(PackageAssert{Package: E, Value: true}))
Expect(solution).To(ContainElement(PackageAssert{Package: F, Value: true}))
Expect(len(solution)).To(Equal(3))
Expect(len(solution)).To(Equal(6))
})
})

View File

@@ -167,7 +167,6 @@ func (s *Solver) BuildWorld(includeInstalled bool) (bf.Formula, error) {
}
for _, p := range s.World() {
solvable, err := p.BuildFormula(s.DefinitionDatabase, s.SolverDatabase)
if err != nil {
return nil, err

View File

@@ -111,7 +111,7 @@ var _ = Describe("Solver", func() {
// Expect(solution).To(ContainElement(PackageAssert{Package: B, Value: false}))
//Expect(solution).To(ContainElement(PackageAssert{Package: D, Value: false}))
Expect(len(solution)).To(Equal(3))
Expect(len(solution)).To(Equal(5))
})
It("Solves correctly if the selected package to install has requirements", func() {
@@ -1283,7 +1283,37 @@ var _ = Describe("Solver", func() {
})
It("upgrades correctly with provides", func() {
B.SetProvides([]*pkg.DefaultPackage{&pkg.DefaultPackage{Name: "a", Version: ">=0", Category: "test"}, &pkg.DefaultPackage{Name: "c", Version: ">=0", Category: "test"}})
B.SetProvides([]*pkg.DefaultPackage{
&pkg.DefaultPackage{Name: "a", Version: ">=0", Category: "test"},
&pkg.DefaultPackage{Name: "c", Version: ">=0", Category: "test"},
})
for _, p := range []pkg.Package{B} {
_, err := dbDefinitions.CreatePackage(p)
Expect(err).ToNot(HaveOccurred())
}
for _, p := range []pkg.Package{A, C} {
_, err := dbInstalled.CreatePackage(p)
Expect(err).ToNot(HaveOccurred())
}
uninstall, solution, err := s.Upgrade(true, true)
Expect(err).ToNot(HaveOccurred())
Expect(len(uninstall)).To(Equal(2))
Expect(uninstall).To(ContainElement(C))
Expect(uninstall).To(ContainElement(A))
Expect(solution).To(ContainElement(PackageAssert{Package: B, Value: true}))
Expect(len(solution)).To(Equal(1))
})
PIt("upgrades correctly with provides, also if definitiondb contains both a provide, and the package to be provided", func() {
B.SetProvides([]*pkg.DefaultPackage{
&pkg.DefaultPackage{Name: "a", Version: ">=0", Category: "test"},
&pkg.DefaultPackage{Name: "c", Version: ">=0", Category: "test"},
})
for _, p := range []pkg.Package{A1, B} {
_, err := dbDefinitions.CreatePackage(p)
@@ -1298,10 +1328,9 @@ var _ = Describe("Solver", func() {
Expect(err).ToNot(HaveOccurred())
Expect(len(uninstall)).To(Equal(2))
Expect(uninstall[1].GetName()).To(Equal("c"))
Expect(uninstall[1].GetVersion()).To(Equal("1.5"))
Expect(uninstall[0].GetName()).To(Equal("a"))
Expect(uninstall[0].GetVersion()).To(Equal("1.1"))
Expect(uninstall).To(ContainElement(C))
Expect(uninstall).To(ContainElement(A))
Expect(solution).To(ContainElement(PackageAssert{Package: B, Value: true}))
Expect(len(solution)).To(Equal(1))