From a3f916817cac3e75c85dc6ec4432397410d3d21b Mon Sep 17 00:00:00 2001 From: Anatolii Bazko Date: Wed, 28 Jul 2021 17:27:37 +0300 Subject: [PATCH] Fix tests Signed-off-by: Anatolii Bazko --- config/samples/org.eclipse.che_v1_checluster.yaml | 2 +- controllers/che/checluster_controller_test.go | 6 +++++- controllers/che/proxy_test.go | 10 +--------- controllers/che/workspace_namespace_permission_test.go | 10 +--------- 4 files changed, 8 insertions(+), 20 deletions(-) diff --git a/config/samples/org.eclipse.che_v1_checluster.yaml b/config/samples/org.eclipse.che_v1_checluster.yaml index 8b9b5e94f..f87f8e6f5 100644 --- a/config/samples/org.eclipse.che_v1_checluster.yaml +++ b/config/samples/org.eclipse.che_v1_checluster.yaml @@ -136,7 +136,7 @@ spec: oAuthSecret: '' k8s: # Global ingress domain for a Kubernetes cluster. - ingressDomain: '192.168.99.100.nip.io' + ingressDomain: '192.168.99.101.nip.io' # Ingress class that will define the which controller will manage ingresses. Defaults to `nginx`. # NB: This drives the `kubernetes.io/ingress.class` annotation on Che-related ingresses. ingressClass: '' diff --git a/controllers/che/checluster_controller_test.go b/controllers/che/checluster_controller_test.go index 4604372bd..65bf0b0b7 100644 --- a/controllers/che/checluster_controller_test.go +++ b/controllers/che/checluster_controller_test.go @@ -869,6 +869,7 @@ func TestImagePullerConfiguration(t *testing.T) { Namespace: namespace, }, } + _, err := r.Reconcile(req) if err != nil { t.Fatalf("Error reconciling: %v", err) @@ -901,9 +902,12 @@ func TestImagePullerConfiguration(t *testing.T) { if err != nil { t.Errorf("Error getting CheCluster: %v", err) } - if !reflect.DeepEqual(testCase.expectedCR, gotCR) { + if !reflect.DeepEqual(testCase.expectedCR.Spec.ImagePuller, gotCR.Spec.ImagePuller) { t.Errorf("Expected CR and CR returned from API server are different (-want +got): %v", cmp.Diff(testCase.expectedCR, gotCR)) } + if testCase.expectedCR.Spec.ImagePuller.Enable && !util.ContainsString(testCase.expectedCR.ObjectMeta.Finalizers, "kubernetesimagepullers.finalizers.che.eclipse.org") { + t.Errorf("kubernetesimagepullers.finalizers.che.eclipse.org finalizer was not added.") + } } if testCase.expectedImagePuller != nil { gotImagePuller := &chev1alpha1.KubernetesImagePuller{} diff --git a/controllers/che/proxy_test.go b/controllers/che/proxy_test.go index 9c420d298..6fe4b4b23 100644 --- a/controllers/che/proxy_test.go +++ b/controllers/che/proxy_test.go @@ -318,7 +318,6 @@ func TestReadProxyConfiguration(t *testing.T) { scheme.AddKnownTypes(configv1.SchemeGroupVersion, &configv1.Proxy{}) cli := fake.NewFakeClientWithScheme(scheme, testCase.initObjects...) - nonCachedClient := fake.NewFakeClientWithScheme(scheme, testCase.initObjects...) clientSet := fakeclientset.NewSimpleClientset() fakeDiscovery, _ := clientSet.Discovery().(*fakeDiscovery.FakeDiscovery) fakeDiscovery.Fake.Resources = []*metav1.APIResourceList{} @@ -326,13 +325,6 @@ func TestReadProxyConfiguration(t *testing.T) { os.Setenv("OPENSHIFT_VERSION", testCase.openShiftVersion) util.IsOpenShift, util.IsOpenShift4, _ = util.DetectOpenShift() - r := &CheClusterReconciler{ - client: cli, - nonCachedClient: nonCachedClient, - discoveryClient: fakeDiscovery, - Scheme: scheme, - } - deployContext := &deploy.DeployContext{ CheCluster: testCase.cheCluster, ClusterAPI: deploy.ClusterAPI{ @@ -342,7 +334,7 @@ func TestReadProxyConfiguration(t *testing.T) { }, } - actualProxyConf, err := r.getProxyConfiguration(deployContext) + actualProxyConf, err := getProxyConfiguration(deployContext) if err != nil { t.Fatalf("Error reading proxy configuration: %v", err) } diff --git a/controllers/che/workspace_namespace_permission_test.go b/controllers/che/workspace_namespace_permission_test.go index 6ce44dae9..b0545224d 100644 --- a/controllers/che/workspace_namespace_permission_test.go +++ b/controllers/che/workspace_namespace_permission_test.go @@ -23,15 +23,7 @@ import ( func TestReconcileWorkspacePermissions(t *testing.T) { deployContext := deploy.GetTestDeployContext(nil, []runtime.Object{}) - reconciler := &CheClusterReconciler{ - client: deployContext.ClusterAPI.Client, - nonCachedClient: deployContext.ClusterAPI.Client, - discoveryClient: deployContext.ClusterAPI.DiscoveryClient, - Scheme: deployContext.ClusterAPI.Scheme, - tests: true, - } - - done, err := reconciler.reconcileWorkspacePermissions(deployContext) + done, err := reconcileWorkspacePermissions(deployContext) if err != nil { t.Fatalf("Failed to reconcile permissions: %v", err) }