From 6108b510f14c5647228662d9fd1dfc5bf8907aa4 Mon Sep 17 00:00:00 2001 From: Anatolii Bazko Date: Mon, 19 Aug 2024 10:21:34 +0200 Subject: [PATCH 1/2] fix: operator tests for DS Signed-off-by: Anatolii Bazko --- pkg/deploy/dashboard/dashboard_deployment_test.go | 10 ++++++++++ pkg/deploy/devfileregistry/devfileregistry_test.go | 13 +++++++++++++ 2 files changed, 23 insertions(+) diff --git a/pkg/deploy/dashboard/dashboard_deployment_test.go b/pkg/deploy/dashboard/dashboard_deployment_test.go index 27b32ff67..90cae4dd2 100644 --- a/pkg/deploy/dashboard/dashboard_deployment_test.go +++ b/pkg/deploy/dashboard/dashboard_deployment_test.go @@ -141,6 +141,16 @@ func TestDashboardDeploymentResources(t *testing.T) { } func TestDashboardDeploymentEnvVars(t *testing.T) { + defaultExternalDevfileRegistriesEnvVar := os.Getenv("CHE_DEFAULT_SPEC_COMPONENTS_DEVFILEREGISTRY_EXTERNAL_DEVFILE_REGISTRIES") + defer func() { + _ = os.Setenv("CHE_DEFAULT_SPEC_COMPONENTS_DEVFILEREGISTRY_EXTERNAL_DEVFILE_REGISTRIES", defaultExternalDevfileRegistriesEnvVar) + }() + + _ = os.Setenv("CHE_DEFAULT_SPEC_COMPONENTS_DEVFILEREGISTRY_EXTERNAL_DEVFILE_REGISTRIES", "[{\"url\": \"https://registry.devfile.io\"}]") + + // re initialize defaults with new env var + defaults.InitializeForTesting("../../../config/manager/manager.yaml") + infrastructure.InitializeForTesting(infrastructure.OpenShiftv4) type resourcesTestCase struct { diff --git a/pkg/deploy/devfileregistry/devfileregistry_test.go b/pkg/deploy/devfileregistry/devfileregistry_test.go index 21c3a53e3..b309433d3 100644 --- a/pkg/deploy/devfileregistry/devfileregistry_test.go +++ b/pkg/deploy/devfileregistry/devfileregistry_test.go @@ -13,8 +13,11 @@ package devfileregistry import ( + "os" "testing" + defaults "github.com/eclipse-che/che-operator/pkg/common/operator-defaults" + "github.com/devfile/devworkspace-operator/pkg/infrastructure" chev2 "github.com/eclipse-che/che-operator/api/v2" "github.com/eclipse-che/che-operator/pkg/common/test" @@ -24,6 +27,16 @@ import ( ) func TestDevfileRegistryReconciler(t *testing.T) { + defaultExternalDevfileRegistriesEnvVar := os.Getenv("CHE_DEFAULT_SPEC_COMPONENTS_DEVFILEREGISTRY_EXTERNAL_DEVFILE_REGISTRIES") + defer func() { + _ = os.Setenv("CHE_DEFAULT_SPEC_COMPONENTS_DEVFILEREGISTRY_EXTERNAL_DEVFILE_REGISTRIES", defaultExternalDevfileRegistriesEnvVar) + }() + + _ = os.Setenv("CHE_DEFAULT_SPEC_COMPONENTS_DEVFILEREGISTRY_EXTERNAL_DEVFILE_REGISTRIES", "[{\"url\": \"https://registry.devfile.io\"}]") + + // re initialize defaults with new env var + defaults.InitializeForTesting("../../../config/manager/manager.yaml") + type testCase struct { name string cheCluster *chev2.CheCluster From 9aec7d00d9cfc773b8cf78b2ccf48b342019825e Mon Sep 17 00:00:00 2001 From: Anatolii Bazko Date: Mon, 19 Aug 2024 10:49:46 +0200 Subject: [PATCH 2/2] fix: operator tests for DS Signed-off-by: Anatolii Bazko --- pkg/deploy/dashboard/dashboard_deployment_test.go | 10 ---------- pkg/deploy/devfileregistry/devfileregistry_test.go | 2 +- 2 files changed, 1 insertion(+), 11 deletions(-) diff --git a/pkg/deploy/dashboard/dashboard_deployment_test.go b/pkg/deploy/dashboard/dashboard_deployment_test.go index 90cae4dd2..27b32ff67 100644 --- a/pkg/deploy/dashboard/dashboard_deployment_test.go +++ b/pkg/deploy/dashboard/dashboard_deployment_test.go @@ -141,16 +141,6 @@ func TestDashboardDeploymentResources(t *testing.T) { } func TestDashboardDeploymentEnvVars(t *testing.T) { - defaultExternalDevfileRegistriesEnvVar := os.Getenv("CHE_DEFAULT_SPEC_COMPONENTS_DEVFILEREGISTRY_EXTERNAL_DEVFILE_REGISTRIES") - defer func() { - _ = os.Setenv("CHE_DEFAULT_SPEC_COMPONENTS_DEVFILEREGISTRY_EXTERNAL_DEVFILE_REGISTRIES", defaultExternalDevfileRegistriesEnvVar) - }() - - _ = os.Setenv("CHE_DEFAULT_SPEC_COMPONENTS_DEVFILEREGISTRY_EXTERNAL_DEVFILE_REGISTRIES", "[{\"url\": \"https://registry.devfile.io\"}]") - - // re initialize defaults with new env var - defaults.InitializeForTesting("../../../config/manager/manager.yaml") - infrastructure.InitializeForTesting(infrastructure.OpenShiftv4) type resourcesTestCase struct { diff --git a/pkg/deploy/devfileregistry/devfileregistry_test.go b/pkg/deploy/devfileregistry/devfileregistry_test.go index b309433d3..15c8b3367 100644 --- a/pkg/deploy/devfileregistry/devfileregistry_test.go +++ b/pkg/deploy/devfileregistry/devfileregistry_test.go @@ -35,7 +35,7 @@ func TestDevfileRegistryReconciler(t *testing.T) { _ = os.Setenv("CHE_DEFAULT_SPEC_COMPONENTS_DEVFILEREGISTRY_EXTERNAL_DEVFILE_REGISTRIES", "[{\"url\": \"https://registry.devfile.io\"}]") // re initialize defaults with new env var - defaults.InitializeForTesting("../../../config/manager/manager.yaml") + defaults.Initialize() type testCase struct { name string