Skip to content

Commit d358c64

Browse files
committed
Set env variable for tests
1 parent 9c4d011 commit d358c64

1 file changed

Lines changed: 8 additions & 0 deletions

File tree

internal/controller/console/catalog_test.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package console
22

33
import (
44
"context"
5+
"os"
56
"testing"
67

78
appsv1 "k8s.io/api/apps/v1"
@@ -12,6 +13,13 @@ import (
1213
"sigs.k8s.io/controller-runtime/pkg/client/fake"
1314
)
1415

16+
func TestMain(m *testing.M) {
17+
// Ensure getDeploymentNamespace() always returns defaultNamespace in tests,
18+
// regardless of whether /var/run/secrets/.../namespace exists (e.g. in CI).
19+
os.Setenv("OPERATOR_NAMESPACE", defaultNamespace)
20+
os.Exit(m.Run())
21+
}
22+
1523
func newOperatorConfigMap(image string) *corev1.ConfigMap {
1624
data := map[string]string{}
1725
if image != "" {

0 commit comments

Comments
 (0)