mirror of
https://github.com/mudler/luet.git
synced 2025-08-29 12:13:09 +00:00
If provided isn't a selector, it means we don't have to return a range
Add also more tests about provides
This commit is contained in:
parent
921869d04c
commit
ce169f49af
@ -330,6 +330,9 @@ func (db *InMemoryDatabase) FindPackages(p Package) (Packages, error) {
|
|||||||
// Provides: Treat as the replaced package here
|
// Provides: Treat as the replaced package here
|
||||||
if provided, err := db.getProvide(p); err == nil {
|
if provided, err := db.getProvide(p); err == nil {
|
||||||
p = provided
|
p = provided
|
||||||
|
if !provided.IsSelector() {
|
||||||
|
return Packages{provided}, nil
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
db.Lock()
|
db.Lock()
|
||||||
|
@ -98,7 +98,9 @@ var _ = Describe("Database", func() {
|
|||||||
|
|
||||||
})
|
})
|
||||||
|
|
||||||
It("Provides replaces definitions", func() {
|
Context("Provides", func() {
|
||||||
|
|
||||||
|
It("replaces definitions", func() {
|
||||||
db := NewInMemoryDatabase(false)
|
db := NewInMemoryDatabase(false)
|
||||||
a := NewPackage("A", "1.0", []*DefaultPackage{}, []*DefaultPackage{})
|
a := NewPackage("A", "1.0", []*DefaultPackage{}, []*DefaultPackage{})
|
||||||
a1 := NewPackage("A", "1.1", []*DefaultPackage{}, []*DefaultPackage{})
|
a1 := NewPackage("A", "1.1", []*DefaultPackage{}, []*DefaultPackage{})
|
||||||
@ -122,6 +124,124 @@ var _ = Describe("Database", func() {
|
|||||||
Expect(err).ToNot(HaveOccurred())
|
Expect(err).ToNot(HaveOccurred())
|
||||||
Expect(pack).To(Equal(a3))
|
Expect(pack).To(Equal(a3))
|
||||||
})
|
})
|
||||||
|
|
||||||
|
It("replaces definitions", func() {
|
||||||
|
db := NewInMemoryDatabase(false)
|
||||||
|
a := NewPackage("A", "1.0", []*DefaultPackage{}, []*DefaultPackage{})
|
||||||
|
a1 := NewPackage("A", "1.1", []*DefaultPackage{}, []*DefaultPackage{})
|
||||||
|
a3 := NewPackage("A", "1.3", []*DefaultPackage{}, []*DefaultPackage{})
|
||||||
|
|
||||||
|
a3.SetProvides([]*DefaultPackage{{Name: "A", Category: "", Version: "1.0"}})
|
||||||
|
Expect(a3.GetProvides()).To(Equal([]*DefaultPackage{{Name: "A", Category: "", Version: "1.0"}}))
|
||||||
|
|
||||||
|
_, err := db.CreatePackage(a)
|
||||||
|
Expect(err).ToNot(HaveOccurred())
|
||||||
|
|
||||||
|
_, err = db.CreatePackage(a1)
|
||||||
|
Expect(err).ToNot(HaveOccurred())
|
||||||
|
|
||||||
|
_, err = db.CreatePackage(a3)
|
||||||
|
Expect(err).ToNot(HaveOccurred())
|
||||||
|
|
||||||
|
s := NewPackage("A", "1.0", []*DefaultPackage{}, []*DefaultPackage{})
|
||||||
|
|
||||||
|
packs, err := db.FindPackages(s)
|
||||||
|
Expect(err).ToNot(HaveOccurred())
|
||||||
|
Expect(packs).To(ContainElement(a3))
|
||||||
|
})
|
||||||
|
|
||||||
|
It("replaces definitions", func() {
|
||||||
|
db := NewInMemoryDatabase(false)
|
||||||
|
a := NewPackage("A", "1.0", []*DefaultPackage{}, []*DefaultPackage{})
|
||||||
|
a1 := NewPackage("A", "1.1", []*DefaultPackage{}, []*DefaultPackage{})
|
||||||
|
z := NewPackage("Z", "1.3", []*DefaultPackage{}, []*DefaultPackage{})
|
||||||
|
|
||||||
|
z.SetProvides([]*DefaultPackage{{Name: "A", Category: "", Version: ">=1.0"}})
|
||||||
|
Expect(z.GetProvides()).To(Equal([]*DefaultPackage{{Name: "A", Category: "", Version: ">=1.0"}}))
|
||||||
|
|
||||||
|
_, err := db.CreatePackage(a)
|
||||||
|
Expect(err).ToNot(HaveOccurred())
|
||||||
|
|
||||||
|
_, err = db.CreatePackage(a1)
|
||||||
|
Expect(err).ToNot(HaveOccurred())
|
||||||
|
|
||||||
|
_, err = db.CreatePackage(z)
|
||||||
|
Expect(err).ToNot(HaveOccurred())
|
||||||
|
|
||||||
|
s := NewPackage("A", "1.0", []*DefaultPackage{}, []*DefaultPackage{})
|
||||||
|
|
||||||
|
packs, err := db.FindPackages(s)
|
||||||
|
Expect(err).ToNot(HaveOccurred())
|
||||||
|
Expect(packs).To(ContainElement(z))
|
||||||
|
})
|
||||||
|
|
||||||
|
It("replaces definitions of unexisting packages", func() {
|
||||||
|
db := NewInMemoryDatabase(false)
|
||||||
|
a1 := NewPackage("A", "1.1", []*DefaultPackage{}, []*DefaultPackage{})
|
||||||
|
z := NewPackage("Z", "1.3", []*DefaultPackage{}, []*DefaultPackage{})
|
||||||
|
|
||||||
|
z.SetProvides([]*DefaultPackage{{Name: "A", Category: "", Version: ">=1.0"}})
|
||||||
|
Expect(z.GetProvides()).To(Equal([]*DefaultPackage{{Name: "A", Category: "", Version: ">=1.0"}}))
|
||||||
|
|
||||||
|
_, err := db.CreatePackage(a1)
|
||||||
|
Expect(err).ToNot(HaveOccurred())
|
||||||
|
|
||||||
|
_, err = db.CreatePackage(z)
|
||||||
|
Expect(err).ToNot(HaveOccurred())
|
||||||
|
|
||||||
|
s := NewPackage("A", "1.0", []*DefaultPackage{}, []*DefaultPackage{})
|
||||||
|
|
||||||
|
packs, err := db.FindPackages(s)
|
||||||
|
Expect(err).ToNot(HaveOccurred())
|
||||||
|
Expect(packs).To(ContainElement(z))
|
||||||
|
})
|
||||||
|
|
||||||
|
It("replaces definitions of a required package", func() {
|
||||||
|
db := NewInMemoryDatabase(false)
|
||||||
|
|
||||||
|
c := NewPackage("C", "1.1", []*DefaultPackage{{Name: "A", Category: "", Version: ">=0"}}, []*DefaultPackage{})
|
||||||
|
z := NewPackage("Z", "1.3", []*DefaultPackage{}, []*DefaultPackage{})
|
||||||
|
|
||||||
|
z.SetProvides([]*DefaultPackage{{Name: "A", Category: "", Version: ">=1.0"}})
|
||||||
|
Expect(z.GetProvides()).To(Equal([]*DefaultPackage{{Name: "A", Category: "", Version: ">=1.0"}}))
|
||||||
|
|
||||||
|
_, err := db.CreatePackage(z)
|
||||||
|
Expect(err).ToNot(HaveOccurred())
|
||||||
|
_, err = db.CreatePackage(c)
|
||||||
|
Expect(err).ToNot(HaveOccurred())
|
||||||
|
|
||||||
|
s := NewPackage("A", "1.0", []*DefaultPackage{}, []*DefaultPackage{})
|
||||||
|
|
||||||
|
packs, err := db.FindPackages(s)
|
||||||
|
Expect(err).ToNot(HaveOccurred())
|
||||||
|
Expect(packs).To(ContainElement(z))
|
||||||
|
})
|
||||||
|
|
||||||
|
When("Searching with selectors", func() {
|
||||||
|
It("replaces definitions of a required package", func() {
|
||||||
|
db := NewInMemoryDatabase(false)
|
||||||
|
|
||||||
|
c := NewPackage("C", "1.1", []*DefaultPackage{{Name: "A", Category: "", Version: ">=0"}}, []*DefaultPackage{})
|
||||||
|
z := NewPackage("Z", "1.3", []*DefaultPackage{}, []*DefaultPackage{})
|
||||||
|
|
||||||
|
z.SetProvides([]*DefaultPackage{{Name: "A", Category: "", Version: ">=1.0"}})
|
||||||
|
Expect(z.GetProvides()).To(Equal([]*DefaultPackage{{Name: "A", Category: "", Version: ">=1.0"}}))
|
||||||
|
|
||||||
|
_, err := db.CreatePackage(z)
|
||||||
|
Expect(err).ToNot(HaveOccurred())
|
||||||
|
_, err = db.CreatePackage(c)
|
||||||
|
Expect(err).ToNot(HaveOccurred())
|
||||||
|
|
||||||
|
s := NewPackage("A", ">=1.0", []*DefaultPackage{}, []*DefaultPackage{})
|
||||||
|
|
||||||
|
packs, err := db.FindPackages(s)
|
||||||
|
Expect(err).ToNot(HaveOccurred())
|
||||||
|
Expect(packs).To(ContainElement(z))
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
})
|
||||||
|
|
||||||
})
|
})
|
||||||
|
|
||||||
})
|
})
|
||||||
|
Loading…
Reference in New Issue
Block a user