|
| 1 | +package variables_test |
| 2 | + |
| 3 | +import ( |
| 4 | + . "github.com/onsi/ginkgo/v2" |
| 5 | + . "github.com/onsi/gomega" |
| 6 | + |
| 7 | + "github.com/operator-framework/deppy/pkg/deppy" |
| 8 | + "github.com/operator-framework/deppy/pkg/deppy/constraint" |
| 9 | + "github.com/operator-framework/deppy/pkg/deppy/input" |
| 10 | + "github.com/operator-framework/operator-registry/alpha/property" |
| 11 | + |
| 12 | + olmentity "github.com/operator-framework/operator-controller/internal/resolution/entities" |
| 13 | + olmvariables "github.com/operator-framework/operator-controller/internal/resolution/variables" |
| 14 | +) |
| 15 | + |
| 16 | +var _ = Describe("BundleVariable", func() { |
| 17 | + var ( |
| 18 | + bv *olmvariables.BundleVariable |
| 19 | + bundleEntity *olmentity.BundleEntity |
| 20 | + dependencies []*olmentity.BundleEntity |
| 21 | + ) |
| 22 | + |
| 23 | + BeforeEach(func() { |
| 24 | + bundleEntity = olmentity.NewBundleEntity(input.NewEntity("bundle-1", map[string]string{ |
| 25 | + property.TypePackage: `{"packageName": "test-package", "version": "1.0.0"}`, |
| 26 | + property.TypeChannel: `{"channelName":"stable","priority":0}`, |
| 27 | + })) |
| 28 | + dependencies = []*olmentity.BundleEntity{ |
| 29 | + olmentity.NewBundleEntity(input.NewEntity("bundle-2", map[string]string{ |
| 30 | + property.TypePackage: `{"packageName": "test-package-2", "version": "2.0.0"}`, |
| 31 | + property.TypeChannel: `{"channelName":"stable","priority":0}`, |
| 32 | + })), |
| 33 | + olmentity.NewBundleEntity(input.NewEntity("bundle-3", map[string]string{ |
| 34 | + property.TypePackage: `{"packageName": "test-package-3", "version": "2.0.0"}`, |
| 35 | + property.TypeChannel: `{"channelName":"stable","priority":0}`, |
| 36 | + })), |
| 37 | + } |
| 38 | + bv = olmvariables.NewBundleVariable(bundleEntity, dependencies) |
| 39 | + }) |
| 40 | + |
| 41 | + It("should return the correct bundle entity", func() { |
| 42 | + Expect(bv.BundleEntity()).To(Equal(bundleEntity)) |
| 43 | + }) |
| 44 | + |
| 45 | + It("should return the correct dependencies", func() { |
| 46 | + Expect(bv.Dependencies()).To(Equal(dependencies)) |
| 47 | + }) |
| 48 | +}) |
| 49 | + |
| 50 | +var _ = Describe("BundleUniquenessVariable", func() { |
| 51 | + var ( |
| 52 | + id deppy.Identifier |
| 53 | + atMostIDs []deppy.Identifier |
| 54 | + globalConstraintVariable *olmvariables.BundleUniquenessVariable |
| 55 | + ) |
| 56 | + |
| 57 | + BeforeEach(func() { |
| 58 | + id = deppy.IdentifierFromString("test-id") |
| 59 | + atMostIDs = []deppy.Identifier{ |
| 60 | + deppy.IdentifierFromString("test-at-most-id-1"), |
| 61 | + deppy.IdentifierFromString("test-at-most-id-2"), |
| 62 | + } |
| 63 | + globalConstraintVariable = olmvariables.NewBundleUniquenessVariable(id, atMostIDs...) |
| 64 | + }) |
| 65 | + |
| 66 | + It("should initialize a new global constraint variable", func() { |
| 67 | + Expect(globalConstraintVariable.Identifier()).To(Equal(id)) |
| 68 | + Expect(globalConstraintVariable.Constraints()).To(Equal([]deppy.Constraint{constraint.AtMost(1, atMostIDs...)})) |
| 69 | + }) |
| 70 | +}) |
0 commit comments