1
1
package variables_test
2
2
3
3
import (
4
- . "github.com/onsi/ginkgo/v2"
5
- . "github.com/onsi/gomega"
4
+ "testing"
6
5
7
6
"github.com/operator-framework/deppy/pkg/deppy"
8
7
"github.com/operator-framework/deppy/pkg/deppy/constraint"
@@ -13,58 +12,49 @@ import (
13
12
olmvariables "github.com/operator-framework/operator-controller/internal/resolution/variables"
14
13
)
15
14
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"}` ,
15
+ func TestBundleVariable (t * testing.T ) {
16
+ bundleEntity := olmentity .NewBundleEntity (input .NewEntity ("bundle-1" , map [string ]string {
17
+ property .TypePackage : `{"packageName": "test-package", "version": "1.0.0"}` ,
18
+ property .TypeChannel : `{"channelName":"stable","priority":0}` ,
19
+ }))
20
+ dependencies := []* olmentity.BundleEntity {
21
+ olmentity .NewBundleEntity (input .NewEntity ("bundle-2" , map [string ]string {
22
+ property .TypePackage : `{"packageName": "test-package-2", "version": "2.0.0"}` ,
23
+ property .TypeChannel : `{"channelName":"stable","priority":0}` ,
24
+ })),
25
+ olmentity .NewBundleEntity (input .NewEntity ("bundle-3" , map [string ]string {
26
+ property .TypePackage : `{"packageName": "test-package-3", "version": "2.0.0"}` ,
26
27
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
- })),
28
+ })),
29
+ }
30
+ bv := olmvariables . NewBundleVariable ( bundleEntity , dependencies )
31
+
32
+ if bv . BundleEntity () != bundleEntity {
33
+ t . Errorf ( "bundle entity '%v' does not match expected '%v'" , bv . BundleEntity (), bundleEntity )
34
+ }
35
+ for i , d := range bv . Dependencies () {
36
+ if d != dependencies [ i ] {
37
+ t . Errorf ( "dependency[%v] '%v' does not match expected '%v'" , i , d , dependencies [ i ])
37
38
}
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" ),
39
+ }
40
+ }
41
+
42
+ func TestBundleUniquenessVariable (t * testing.T ) {
43
+ id := deppy .IdentifierFromString ("test-id" )
44
+ atMostIDs := []deppy.Identifier {
45
+ deppy .IdentifierFromString ("test-at-most-id-1" ),
46
+ deppy .IdentifierFromString ("test-at-most-id-2" ),
47
+ }
48
+ globalConstraintVariable := olmvariables .NewBundleUniquenessVariable (id , atMostIDs ... )
49
+
50
+ if globalConstraintVariable .Identifier () != id {
51
+ t .Errorf ("identifier '%v' does not match expected '%v'" , globalConstraintVariable .Identifier (), id )
52
+ }
53
+
54
+ constraints := []deppy.Constraint {constraint .AtMost (1 , atMostIDs ... )}
55
+ for i , c := range globalConstraintVariable .Constraints () {
56
+ if c .String ("test" ) != constraints [i ].String ("test" ) {
57
+ t .Errorf ("constraint[%v] '%v' does not match expected '%v'" , i , c , constraints [i ])
62
58
}
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
- })
59
+ }
60
+ }
0 commit comments