44 "context"
55 "testing"
66
7- consolepluginv1 "github.com/openshift/api/console/v1alpha1 "
7+ consolev1 "github.com/openshift/api/console/v1 "
88 pipelinesv1alpha1 "github.com/redhat-developer/gitops-operator/api/v1alpha1"
99 "gotest.tools/assert"
1010 appsv1 "k8s.io/api/apps/v1"
@@ -25,13 +25,15 @@ func TestPlugin(t *testing.T) {
2525 testDisplayName := displayName
2626 assert .Equal (t , testConsolePlugin .Spec .DisplayName , testDisplayName )
2727
28- testPluginService := consolepluginv1 .ConsolePluginService {
28+ testPluginService := & consolev1 .ConsolePluginService {
2929 Name : gitopsPluginName ,
3030 Namespace : serviceNamespace ,
3131 Port : servicePort ,
3232 BasePath : "/" ,
3333 }
34- assert .DeepEqual (t , testConsolePlugin .Spec .Service , testPluginService )
34+ assert .DeepEqual (t , testConsolePlugin .Spec .I18n .LoadType , consolev1 .Preload )
35+ assert .DeepEqual (t , testConsolePlugin .Spec .Backend .Type , consolev1 .Service )
36+ assert .DeepEqual (t , testConsolePlugin .Spec .Backend .Service , testPluginService )
3537}
3638
3739func TestPlugin_reconcileDeployment_changedLabels (t * testing.T ) {
@@ -1388,7 +1390,7 @@ func TestPlugin_reconcileConsolePlugin(t *testing.T) {
13881390 _ , err := reconciler .reconcileConsolePlugin (instance , newRequest (serviceNamespace , gitopsPluginName ))
13891391 assertNoError (t , err )
13901392
1391- consolePlugin := & consolepluginv1 .ConsolePlugin {}
1393+ consolePlugin := & consolev1 .ConsolePlugin {}
13921394 err = fakeClient .Get (context .TODO (), types.NamespacedName {Name : gitopsPluginName }, consolePlugin )
13931395 assertNoError (t , err )
13941396}
@@ -1417,17 +1419,20 @@ func TestPlugin_reconcileConsolePlugin_changedDisplayName(t *testing.T) {
14171419
14181420 for _ , test := range tests {
14191421 t .Run (test .name , func (t * testing.T ) {
1420- cp := & consolepluginv1 .ConsolePlugin {
1422+ cp := & consolev1 .ConsolePlugin {
14211423 ObjectMeta : metav1.ObjectMeta {
14221424 Name : gitopsPluginName ,
14231425 },
1424- Spec : consolepluginv1 .ConsolePluginSpec {
1426+ Spec : consolev1 .ConsolePluginSpec {
14251427 DisplayName : test .displayName ,
1426- Service : consolepluginv1.ConsolePluginService {
1427- Name : gitopsPluginName ,
1428- Namespace : serviceNamespace ,
1429- Port : servicePort ,
1430- BasePath : "/" ,
1428+ Backend : consolev1.ConsolePluginBackend {
1429+ Type : consolev1 .Service ,
1430+ Service : & consolev1.ConsolePluginService {
1431+ Name : gitopsPluginName ,
1432+ Namespace : serviceNamespace ,
1433+ Port : servicePort ,
1434+ BasePath : "/" ,
1435+ },
14311436 },
14321437 },
14331438 }
@@ -1436,7 +1441,7 @@ func TestPlugin_reconcileConsolePlugin_changedDisplayName(t *testing.T) {
14361441 _ , err := reconciler .reconcileConsolePlugin (instance , newRequest (serviceNamespace , gitopsPluginName ))
14371442 assertNoError (t , err )
14381443
1439- consolePlugin := & consolepluginv1 .ConsolePlugin {}
1444+ consolePlugin := & consolev1 .ConsolePlugin {}
14401445 err = fakeClient .Get (context .TODO (), types.NamespacedName {Name : gitopsPluginName }, consolePlugin )
14411446 assertNoError (t , err )
14421447
@@ -1447,11 +1452,11 @@ func TestPlugin_reconcileConsolePlugin_changedDisplayName(t *testing.T) {
14471452func TestPlugin_reconcileConsolePlugin_changedService (t * testing.T ) {
14481453 tests := []struct {
14491454 name string
1450- service consolepluginv1 .ConsolePluginService
1455+ service consolev1 .ConsolePluginService
14511456 }{
14521457 {
14531458 name : "default service" ,
1454- service : consolepluginv1 .ConsolePluginService {
1459+ service : consolev1 .ConsolePluginService {
14551460 Name : gitopsPluginName ,
14561461 Namespace : serviceNamespace ,
14571462 Port : servicePort ,
@@ -1460,7 +1465,7 @@ func TestPlugin_reconcileConsolePlugin_changedService(t *testing.T) {
14601465 },
14611466 {
14621467 name : "changed service" ,
1463- service : consolepluginv1 .ConsolePluginService {
1468+ service : consolev1 .ConsolePluginService {
14641469 Name : "wrong name" ,
14651470 Namespace : "wrong namespace" ,
14661471 Port : int32 (9002 ),
@@ -1478,28 +1483,31 @@ func TestPlugin_reconcileConsolePlugin_changedService(t *testing.T) {
14781483
14791484 for _ , test := range tests {
14801485 t .Run (test .name , func (t * testing.T ) {
1481- cp := & consolepluginv1 .ConsolePlugin {
1486+ cp := & consolev1 .ConsolePlugin {
14821487 ObjectMeta : metav1.ObjectMeta {
14831488 Name : gitopsPluginName ,
14841489 },
1485- Spec : consolepluginv1 .ConsolePluginSpec {
1490+ Spec : consolev1 .ConsolePluginSpec {
14861491 DisplayName : displayName ,
1487- Service : test .service ,
1492+ Backend : consolev1.ConsolePluginBackend {
1493+ Type : consolev1 .Service ,
1494+ Service : & test .service ,
1495+ },
14881496 },
14891497 }
14901498 reconciler .Client .Create (context .TODO (), cp )
14911499
14921500 _ , err := reconciler .reconcileConsolePlugin (instance , newRequest (serviceNamespace , gitopsPluginName ))
14931501 assertNoError (t , err )
14941502
1495- consolePlugin := & consolepluginv1 .ConsolePlugin {}
1503+ consolePlugin := & consolev1 .ConsolePlugin {}
14961504 err = fakeClient .Get (context .TODO (), types.NamespacedName {Name : gitopsPluginName }, consolePlugin )
14971505 assertNoError (t , err )
14981506
1499- assert .Equal (t , consolePlugin .Spec .Service .Name , "gitops-plugin" )
1500- assert .Equal (t , consolePlugin .Spec .Service .Namespace , "openshift-gitops" )
1501- assert .Equal (t , consolePlugin .Spec .Service .Port , int32 (9001 ))
1502- assert .Equal (t , consolePlugin .Spec .Service .BasePath , "/" )
1507+ assert .Equal (t , consolePlugin .Spec .Backend . Service .Name , "gitops-plugin" )
1508+ assert .Equal (t , consolePlugin .Spec .Backend . Service .Namespace , "openshift-gitops" )
1509+ assert .Equal (t , consolePlugin .Spec .Backend . Service .Port , int32 (9001 ))
1510+ assert .Equal (t , consolePlugin .Spec .Backend . Service .BasePath , "/" )
15031511 })
15041512 }
15051513}
0 commit comments