7
7
"testing"
8
8
9
9
"github.com/stretchr/testify/assert"
10
+ "github.com/stretchr/testify/mock"
10
11
"github.com/stretchr/testify/require"
11
12
apimeta "k8s.io/apimachinery/pkg/api/meta"
12
13
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
@@ -16,6 +17,7 @@ import (
16
17
17
18
"github.com/operator-framework/operator-registry/alpha/declcfg"
18
19
"github.com/operator-framework/operator-registry/alpha/property"
20
+ "github.com/operator-framework/rukpak/pkg/source"
19
21
20
22
ocv1alpha1 "github.com/operator-framework/operator-controller/api/v1alpha1"
21
23
"github.com/operator-framework/operator-controller/internal/catalogmetadata"
@@ -31,7 +33,6 @@ func TestClusterExtensionRegistryV1DisallowDependencies(t *testing.T) {
31
33
name string
32
34
bundle * catalogmetadata.Bundle
33
35
wantErr string
34
- skip bool
35
36
}{
36
37
{
37
38
name : "package with no dependencies" ,
@@ -46,9 +47,6 @@ func TestClusterExtensionRegistryV1DisallowDependencies(t *testing.T) {
46
47
},
47
48
CatalogName : "fake-catalog" ,
48
49
},
49
- // Skipping the happy path, since it requires us to mock unpacker, store and the
50
- // entire installation. This should be handled in an e2e instead.
51
- skip : true ,
52
50
},
53
51
{
54
52
name : "package with olm.package.required property" ,
@@ -103,16 +101,20 @@ func TestClusterExtensionRegistryV1DisallowDependencies(t *testing.T) {
103
101
defer func () {
104
102
require .NoError (t , cl .DeleteAllOf (ctx , & ocv1alpha1.ClusterExtension {}))
105
103
}()
106
-
107
- if tt .skip {
108
- return
109
- }
110
-
111
104
fakeCatalogClient := testutil .NewFakeCatalogClient ([]* catalogmetadata.Bundle {tt .bundle })
105
+ mockUnpacker := unpacker .(* MockUnpacker )
106
+ // Verify if mockUnpacker is correctly set
107
+ t .Log ("MockUnpacker set to:" , mockUnpacker )
108
+ // Set up the Unpack method to return a result with StatePending
109
+ mockUnpacker .On ("Unpack" , mock .Anything , mock .AnythingOfType ("*v1alpha2.BundleDeployment" )).Return (& source.Result {
110
+ State : source .StatePending ,
111
+ }, nil )
112
+
112
113
reconciler := & controllers.ClusterExtensionReconciler {
113
114
Client : cl ,
114
115
BundleProvider : & fakeCatalogClient ,
115
116
ActionClientGetter : helmClientGetter ,
117
+ Unpacker : unpacker ,
116
118
}
117
119
118
120
installNamespace := fmt .Sprintf ("test-ns-%s" , rand .String (8 ))
0 commit comments