Add packageset

This commit is contained in:
Ettore Di Giacinto 2019-07-27 11:29:39 +02:00
parent db90a8f69c
commit 0813f75546
No known key found for this signature in database
GPG Key ID: 1ADA699B145A2D1C
2 changed files with 24 additions and 2 deletions

View File

@ -52,6 +52,29 @@ type Package interface {
GetUses() []string
}
type PackageSet interface {
GetPackages() []Package
AddPackages(pkgs []Package)
}
type DefaultPackages struct {
Packages []Package
}
type Tree interface {
GetPackageSet() PackageSet
}
func (pkgs *DefaultPackages) GetPackages() []Package {
return pkgs.Packages
}
func (p *DefaultPackages) AddPackages(pkgs []Package) {
p.Packages = append(p.Packages, pkgs...)
}
func NewPackages(p []Package) PackageSet { return &DefaultPackages{Packages: p} }
// DefaultPackage represent a standard package definition
type DefaultPackage struct {
Name string

View File

@ -16,7 +16,6 @@
package pkg_test
import (
"github.com/crillab/gophersat/bf"
. "github.com/mudler/luet/pkg/package"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
@ -84,7 +83,7 @@ var _ = Describe("Package", func() {
a1 := NewPackage("A", "1.0", []*DefaultPackage{}, []*DefaultPackage{})
f, err := a1.BuildFormula()
Expect(err).ToNot(HaveOccurred())
Expect(f).To(Equal([]bf.Formula(nil)))
Expect(f).To(BeNil())
})
It("builds constraints correctly", func() {
a11 := NewPackage("A", "1.1", []*DefaultPackage{}, []*DefaultPackage{})