44 "fmt"
55 "testing"
66
7+ "github.com/blang/semver"
78 "github.com/operator-framework/operator-registry/pkg/registry"
89 opregistry "github.com/operator-framework/operator-registry/pkg/registry"
910 "github.com/stretchr/testify/require"
@@ -12,6 +13,8 @@ import (
1213 "github.com/operator-framework/operator-lifecycle-manager/pkg/api/apis/operators/v1alpha1"
1314)
1415
16+ var NoVersion = semver .MustParse ("0.0.0" )
17+
1518func TestNewGenerationFromCSVs (t * testing.T ) {
1619 type args struct {
1720 csvs []* v1alpha1.ClusterServiceVersion
@@ -82,6 +85,7 @@ func TestNewGenerationFromCSVs(t *testing.T) {
8285 },
8386 requiredAPIs : EmptyAPISet (),
8487 sourceInfo : & ExistingOperator ,
88+ version : & NoVersion ,
8589 },
8690 {Group : "g" , Version : "v1" , Kind : "CRDKind" , Plural : "crdkinds" }: & Operator {
8791 name : "operator.v1" ,
@@ -91,6 +95,7 @@ func TestNewGenerationFromCSVs(t *testing.T) {
9195 },
9296 requiredAPIs : EmptyAPISet (),
9397 sourceInfo : & ExistingOperator ,
98+ version : & NoVersion ,
9499 },
95100 },
96101 requiredAPIs : EmptyAPIMultiOwnerSet (),
@@ -142,6 +147,7 @@ func TestNewGenerationFromCSVs(t *testing.T) {
142147 {Group : "g" , Version : "v1" , Kind : "CRDKind" , Plural : "crdkinds" }: {},
143148 },
144149 sourceInfo : & ExistingOperator ,
150+ version : & NoVersion ,
145151 },
146152 },
147153 {Group : "g" , Version : "v1" , Kind : "CRDKind" , Plural : "crdkinds" }: map [string ]OperatorSurface {
@@ -153,6 +159,7 @@ func TestNewGenerationFromCSVs(t *testing.T) {
153159 {Group : "g" , Version : "v1" , Kind : "CRDKind" , Plural : "crdkinds" }: {},
154160 },
155161 sourceInfo : & ExistingOperator ,
162+ version : & NoVersion ,
156163 },
157164 },
158165 },
@@ -170,6 +177,7 @@ func TestNewGenerationFromCSVs(t *testing.T) {
170177 {Group : "g" , Version : "v1" , Kind : "CRDKind" , Plural : "crdkinds" }: {},
171178 },
172179 sourceInfo : & ExistingOperator ,
180+ version : & NoVersion ,
173181 },
174182 },
175183 {Group : "g" , Version : "v1" , Kind : "CRDKind" , Plural : "crdkinds" }: map [string ]OperatorSurface {
@@ -181,6 +189,7 @@ func TestNewGenerationFromCSVs(t *testing.T) {
181189 {Group : "g" , Version : "v1" , Kind : "CRDKind" , Plural : "crdkinds" }: {},
182190 },
183191 sourceInfo : & ExistingOperator ,
192+ version : & NoVersion ,
184193 },
185194 },
186195 },
@@ -246,6 +255,7 @@ func TestNewGenerationFromCSVs(t *testing.T) {
246255 {Group : "g2" , Version : "v1" , Kind : "CRDReqKind" , Plural : "crdreqkinds" }: {},
247256 },
248257 sourceInfo : & ExistingOperator ,
258+ version : & NoVersion ,
249259 },
250260 {Group : "g" , Version : "v1" , Kind : "CRDOwnedKind" , Plural : "crdownedkinds" }: & Operator {
251261 name : "operator.v1" ,
@@ -258,6 +268,7 @@ func TestNewGenerationFromCSVs(t *testing.T) {
258268 {Group : "g2" , Version : "v1" , Kind : "CRDReqKind" , Plural : "crdreqkinds" }: {},
259269 },
260270 sourceInfo : & ExistingOperator ,
271+ version : & NoVersion ,
261272 },
262273 },
263274 requiredAPIs : map [opregistry.APIKey ]OperatorSet {
@@ -273,6 +284,7 @@ func TestNewGenerationFromCSVs(t *testing.T) {
273284 {Group : "g2" , Version : "v1" , Kind : "CRDReqKind" , Plural : "crdreqkinds" }: {},
274285 },
275286 sourceInfo : & ExistingOperator ,
287+ version : & NoVersion ,
276288 },
277289 },
278290 {Group : "g2" , Version : "v1" , Kind : "CRDReqKind" , Plural : "crdreqkinds" }: map [string ]OperatorSurface {
@@ -287,6 +299,7 @@ func TestNewGenerationFromCSVs(t *testing.T) {
287299 {Group : "g2" , Version : "v1" , Kind : "CRDReqKind" , Plural : "crdreqkinds" }: {},
288300 },
289301 sourceInfo : & ExistingOperator ,
302+ version : & NoVersion ,
290303 },
291304 },
292305 },
@@ -307,6 +320,7 @@ func TestNewGenerationFromCSVs(t *testing.T) {
307320 {Group : "g2" , Version : "v1" , Kind : "CRDReqKind" , Plural : "crdreqkinds" }: {},
308321 },
309322 sourceInfo : & ExistingOperator ,
323+ version : & NoVersion ,
310324 },
311325 },
312326 {Group : "g2" , Version : "v1" , Kind : "CRDReqKind" , Plural : "crdreqkinds" }: map [string ]OperatorSurface {
@@ -321,6 +335,7 @@ func TestNewGenerationFromCSVs(t *testing.T) {
321335 {Group : "g2" , Version : "v1" , Kind : "CRDReqKind" , Plural : "crdreqkinds" }: {},
322336 },
323337 sourceInfo : & ExistingOperator ,
338+ version : & NoVersion ,
324339 },
325340 },
326341 },
@@ -334,7 +349,7 @@ func TestNewGenerationFromCSVs(t *testing.T) {
334349 operatorSet := EmptyOperatorSet ()
335350 for _ , csv := range tt .args .csvs {
336351 // there's a separate unit test for this constructor
337- op , err := NewOperatorFromCSV (csv )
352+ op , err := NewOperatorFromV1Alpha1CSV (csv )
338353 require .NoError (t , err )
339354 operatorSet [op .Identifier ()] = op
340355 }
0 commit comments