@@ -22,13 +22,13 @@ func TestOperatorResolver(t *testing.T) {
2222
2323 testEntityCache := map [deppy.Identifier ]input.Entity {"operatorhub/prometheus/0.37.0" : * input .NewEntity (
2424 "operatorhub/prometheus/0.37.0" , map [string ]string {
25- "olm.bundle.path" : `"quay .io/operatorhubio/prometheus@sha256:3e281e587de3d03011440685fc4fb782672beab044c1ebadc42788ce05a21c35 "` ,
25+ "olm.bundle.path" : `"foo .io/bar/baz "` ,
2626 "olm.channel" : "{\" channelName\" :\" beta\" ,\" priority\" :0,\" replaces\" :\" prometheusoperator.0.32.0\" }" ,
2727 "olm.gvk" : "[{\" group\" :\" monitoring.coreos.com\" ,\" kind\" :\" Alertmanager\" ,\" version\" :\" v1\" }, {\" group\" :\" monitoring.coreos.com\" ,\" kind\" :\" Prometheus\" ,\" version\" :\" v1\" }]" ,
2828 "olm.package" : "{\" packageName\" :\" prometheus\" ,\" version\" :\" 0.37.0\" }" ,
2929 }),
3030 "operatorhub/prometheus/0.47.0" : * input .NewEntity ("operatorhub/prometheus/0.47.0" , map [string ]string {
31- "olm.bundle.path" : `"quay .io/operatorhubio/prometheus@sha256:5b04c49d8d3eff6a338b56ec90bdf491d501fe301c9cdfb740e5bff6769a21ed "` ,
31+ "olm.bundle.path" : `"foo .io/bar/baz "` ,
3232 "olm.channel" : "{\" channelName\" :\" beta\" ,\" priority\" :0,\" replaces\" :\" prometheusoperator.0.37.0\" }" ,
3333 "olm.gvk" : "[{\" group\" :\" monitoring.coreos.com\" ,\" kind\" :\" Alertmanager\" ,\" version\" :\" v1\" }, {\" group\" :\" monitoring.coreos.com\" ,\" kind\" :\" Prometheus\" ,\" version\" :\" v1alpha1\" }]" ,
3434 "olm.package" : "{\" packageName\" :\" prometheus\" ,\" version\" :\" 0.47.0\" }" ,
@@ -63,54 +63,53 @@ func TestOperatorResolver(t *testing.T) {
6363 }
6464
6565 for _ , tt := range []struct {
66- Name string
67- Client client.Client
68- EntitySource input.EntitySource
69- SelectedVariables []deppy.Identifier
70- ExpectedError error
66+ name string
67+ client client.Client
68+ entitySource input.EntitySource
69+ expectedSelectedVariables []deppy.Identifier
70+ expectedError error
7171 }{
7272 {
73- Name : "should resolve the packages described by the available Operator resources" ,
74- Client : FakeClient (testResource ... ),
75- EntitySource : testEntitySource ,
76- SelectedVariables : []deppy.Identifier {"operatorhub/packageA/2.0.0" ,
73+ name : "should resolve the packages described by the available Operator resources" ,
74+ client : FakeClient (testResource ... ),
75+ entitySource : testEntitySource ,
76+ expectedSelectedVariables : []deppy.Identifier {
77+ "operatorhub/packageA/2.0.0" ,
7778 "operatorhub/prometheus/0.47.0" ,
7879 "required package packageA" ,
7980 "required package prometheus" },
80- ExpectedError : nil ,
81+ expectedError : nil ,
8182 },
8283 {
83- Name : "should not return an error if there are no Operator resources" ,
84- Client : FakeClient (),
85- EntitySource : testEntitySource ,
86- SelectedVariables : []deppy.Identifier {},
87- ExpectedError : nil ,
84+ name : "should not return an error if there are no Operator resources" ,
85+ client : FakeClient (),
86+ entitySource : testEntitySource ,
87+ expectedSelectedVariables : []deppy.Identifier {},
88+ expectedError : nil ,
8889 },
8990 {
90- Name : "should return an error if the entity source throws an error" ,
91- Client : FakeClient (testResource ... ),
92- EntitySource : FailEntitySource {},
93- ExpectedError : fmt .Errorf ("error calling filter in entity source" ),
91+ name : "should return an error if the entity source throws an error" ,
92+ client : FakeClient (testResource ... ),
93+ entitySource : FailEntitySource {},
94+ expectedError : fmt .Errorf ("error calling filter in entity source" ),
9495 },
9596 {
96- Name : "should return an error if the client throws an error" ,
97- Client : NewFailClientWithError (fmt .Errorf ("something bad happened" )),
98- EntitySource : testEntitySource ,
99- ExpectedError : fmt .Errorf ("something bad happened" ),
97+ name : "should return an error if the client throws an error" ,
98+ client : NewFailClientWithError (fmt .Errorf ("something bad happened" )),
99+ entitySource : testEntitySource ,
100+ expectedError : fmt .Errorf ("something bad happened" ),
100101 },
101102 } {
102- t .Run (tt .Name , func (t * testing.T ) {
103- client := tt .Client
104- entitySource := tt .EntitySource
105- resolver := resolution .NewOperatorResolver (client , entitySource )
103+ t .Run (tt .name , func (t * testing.T ) {
104+ resolver := resolution .NewOperatorResolver (tt .client , tt .entitySource )
106105 solution , err := resolver .Resolve (context .Background ())
107106
108- if tt .ExpectedError != nil {
109- assert .Equal (t , err , tt .ExpectedError )
107+ if tt .expectedError != nil {
108+ assert .Equal (t , tt .expectedError , err )
110109 assert .Nil (t , solution )
111110 } else {
112- assert .Len (t , solution .SelectedVariables (), len (tt .SelectedVariables ))
113- for _ , identifier := range tt .SelectedVariables {
111+ assert .Len (t , solution .SelectedVariables (), len (tt .expectedSelectedVariables ))
112+ for _ , identifier := range tt .expectedSelectedVariables {
114113 assert .True (t , solution .IsSelected (identifier ))
115114 }
116115 assert .NoError (t , err )
0 commit comments