@@ -3,31 +3,28 @@ package joiner
33import (
44 "testing"
55
6- "github.com/openshift/assisted-service/api/hiveextension/v1beta1"
7- fakeclientconfig "github.com/openshift/client-go/config/clientset/versioned/fake"
8- "gopkg.in/yaml.v2"
6+ "github.com/stretchr/testify/assert"
97 corev1 "k8s.io/api/core/v1"
108 v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
119 "k8s.io/apimachinery/pkg/runtime"
12-
1310 "k8s.io/client-go/kubernetes/fake"
14- "k8s.io/client-go/rest "
11+ "sigs. k8s.io/yaml "
1512
1613 configv1 "github.com/openshift/api/config/v1"
14+ "github.com/openshift/assisted-service/api/hiveextension/v1beta1"
15+ fakeclientconfig "github.com/openshift/client-go/config/clientset/versioned/fake"
1716 "github.com/openshift/installer/pkg/asset"
1817 "github.com/openshift/installer/pkg/asset/agent/workflow"
1918 "github.com/openshift/installer/pkg/types"
2019 "github.com/openshift/installer/pkg/types/baremetal"
21- "github.com/stretchr/testify/assert"
2220)
2321
2422func TestClusterInfo_Generate (t * testing.T ) {
2523 cases := []struct {
2624 name string
2725 workflow workflow.AgentWorkflowType
2826 objects []runtime.Object
29- openshiftOjects []runtime.Object
30- configHost string
27+ openshiftObjects []runtime.Object
3128 expectedClusterInfo ClusterInfo
3229 }{
3330 {
@@ -36,10 +33,9 @@ func TestClusterInfo_Generate(t *testing.T) {
3633 expectedClusterInfo : ClusterInfo {},
3734 },
3835 {
39- name : "default" ,
40- workflow : workflow .AgentWorkflowTypeAddNodes ,
41- configHost : "https://api.ostest.test.metalkube.org:6443" ,
42- openshiftOjects : []runtime.Object {
36+ name : "default" ,
37+ workflow : workflow .AgentWorkflowTypeAddNodes ,
38+ openshiftObjects : []runtime.Object {
4339 & configv1.ClusterVersion {
4440 ObjectMeta : v1.ObjectMeta {
4541 Name : "version" ,
@@ -110,6 +106,7 @@ func TestClusterInfo_Generate(t *testing.T) {
110106 },
111107 expectedClusterInfo : ClusterInfo {
112108 ClusterID : "1b5ba46b-7e56-47b1-a326-a9eebddfb38c" ,
109+ ClusterName : "ostest" ,
113110 ReleaseImage : "registry.ci.openshift.org/ocp/release@sha256:65d9b652d0d23084bc45cb66001c22e796d43f5e9e005c2bc2702f94397d596e" ,
114111 Version : "4.15.0" ,
115112 APIDNSName : "api.ostest.test.metalkube.org" ,
@@ -144,20 +141,17 @@ func TestClusterInfo_Generate(t *testing.T) {
144141 parents .Add (addNodesConfig )
145142
146143 fakeClient := fake .NewSimpleClientset (tc .objects ... )
147- fakeOCClient := fakeclientconfig .NewSimpleClientset (tc .openshiftOjects ... )
148- fakeConfig := & rest.Config {
149- Host : tc .configHost ,
150- }
144+ fakeOCClient := fakeclientconfig .NewSimpleClientset (tc .openshiftObjects ... )
151145
152146 clusterInfo := & ClusterInfo {
153- Config : fakeConfig ,
154147 Client : fakeClient ,
155148 OpenshiftClient : fakeOCClient ,
156149 }
157150 err := clusterInfo .Generate (parents )
158151
159152 assert .NoError (t , err )
160153 assert .Equal (t , tc .expectedClusterInfo .ClusterID , clusterInfo .ClusterID )
154+ assert .Equal (t , tc .expectedClusterInfo .ClusterName , clusterInfo .ClusterName )
161155 assert .Equal (t , tc .expectedClusterInfo .Version , clusterInfo .Version )
162156 assert .Equal (t , tc .expectedClusterInfo .ReleaseImage , clusterInfo .ReleaseImage )
163157 assert .Equal (t , tc .expectedClusterInfo .APIDNSName , clusterInfo .APIDNSName )
@@ -175,7 +169,12 @@ func TestClusterInfo_Generate(t *testing.T) {
175169}
176170
177171func makeInstallConfig (t * testing.T ) string {
172+ t .Helper ()
178173 ic := & types.InstallConfig {
174+ ObjectMeta : v1.ObjectMeta {
175+ Name : "ostest" ,
176+ },
177+ BaseDomain : "test.metalkube.org" ,
179178 ImageDigestSources : []types.ImageDigestSource {
180179 {
181180 Source : "quay.io/openshift-release-dev/ocp-v4.0-art-dev" ,
@@ -193,5 +192,6 @@ func makeInstallConfig(t *testing.T) string {
193192 if err != nil {
194193 t .Error (err )
195194 }
195+
196196 return string (data )
197197}
0 commit comments