From 07716832c43af3b8ba81c44fe96d45826714fb64 Mon Sep 17 00:00:00 2001 From: Alexandra Roatis Date: Mon, 23 Nov 2020 17:02:39 -0500 Subject: [PATCH] Using system.Namespace() in tests instead of the hardcoded namespace name --- .../configs/brokerdelivery/br_delivery_defaults_test.go | 7 ++++--- .../configs/dataresidency/dataresidency_defaults_test.go | 7 ++++--- pkg/apis/configs/gcpauth/gcp_auth_defaults_test.go | 5 +++-- 3 files changed, 11 insertions(+), 8 deletions(-) diff --git a/pkg/apis/configs/brokerdelivery/br_delivery_defaults_test.go b/pkg/apis/configs/brokerdelivery/br_delivery_defaults_test.go index 40ceaf3a31..4f9e3ecb54 100644 --- a/pkg/apis/configs/brokerdelivery/br_delivery_defaults_test.go +++ b/pkg/apis/configs/brokerdelivery/br_delivery_defaults_test.go @@ -20,6 +20,7 @@ import ( "testing" "github.com/google/go-cmp/cmp" + "knative.dev/pkg/system" corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" @@ -116,7 +117,7 @@ func TestNewDefaultsConfigFromConfigMapWithError(t *testing.T) { "empty data": { config: &corev1.ConfigMap{ ObjectMeta: metav1.ObjectMeta{ - Namespace: "events-system", + Namespace: system.Namespace(), Name: configName, }, Data: map[string]string{}, @@ -125,7 +126,7 @@ func TestNewDefaultsConfigFromConfigMapWithError(t *testing.T) { "missing key": { config: &corev1.ConfigMap{ ObjectMeta: metav1.ObjectMeta{ - Namespace: "events-system", + Namespace: system.Namespace(), Name: configName, }, Data: map[string]string{ @@ -136,7 +137,7 @@ func TestNewDefaultsConfigFromConfigMapWithError(t *testing.T) { "invalid YAML": { config: &corev1.ConfigMap{ ObjectMeta: metav1.ObjectMeta{ - Namespace: "events-system", + Namespace: system.Namespace(), Name: configName, }, Data: map[string]string{ diff --git a/pkg/apis/configs/dataresidency/dataresidency_defaults_test.go b/pkg/apis/configs/dataresidency/dataresidency_defaults_test.go index 3cf69c4015..6e186d6dc7 100644 --- a/pkg/apis/configs/dataresidency/dataresidency_defaults_test.go +++ b/pkg/apis/configs/dataresidency/dataresidency_defaults_test.go @@ -20,6 +20,7 @@ import ( "testing" "cloud.google.com/go/pubsub" + "knative.dev/pkg/system" "github.com/google/go-cmp/cmp" corev1 "k8s.io/api/core/v1" @@ -126,7 +127,7 @@ func TestNewDefaultsConfigFromConfigMapWithKeyError(t *testing.T) { "empty data": { config: &corev1.ConfigMap{ ObjectMeta: metav1.ObjectMeta{ - Namespace: "events-system", + Namespace: system.Namespace(), Name: configName, }, Data: map[string]string{}, @@ -135,7 +136,7 @@ func TestNewDefaultsConfigFromConfigMapWithKeyError(t *testing.T) { "missing key": { config: &corev1.ConfigMap{ ObjectMeta: metav1.ObjectMeta{ - Namespace: "events-system", + Namespace: system.Namespace(), Name: configName, }, Data: map[string]string{ @@ -146,7 +147,7 @@ func TestNewDefaultsConfigFromConfigMapWithKeyError(t *testing.T) { "wrong format": { config: &corev1.ConfigMap{ ObjectMeta: metav1.ObjectMeta{ - Namespace: "events-system", + Namespace: system.Namespace(), Name: configName, }, Data: map[string]string{ diff --git a/pkg/apis/configs/gcpauth/gcp_auth_defaults_test.go b/pkg/apis/configs/gcpauth/gcp_auth_defaults_test.go index 2deabe138a..65ee172d45 100644 --- a/pkg/apis/configs/gcpauth/gcp_auth_defaults_test.go +++ b/pkg/apis/configs/gcpauth/gcp_auth_defaults_test.go @@ -20,6 +20,7 @@ import ( "testing" "github.com/google/go-cmp/cmp" + "knative.dev/pkg/system" corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" @@ -120,7 +121,7 @@ func TestNewDefaultsConfigFromConfigMapWithError(t *testing.T) { "empty data": { config: &corev1.ConfigMap{ ObjectMeta: metav1.ObjectMeta{ - Namespace: "events-system", + Namespace: system.Namespace(), Name: configName, }, Data: map[string]string{}, @@ -129,7 +130,7 @@ func TestNewDefaultsConfigFromConfigMapWithError(t *testing.T) { "missing key": { config: &corev1.ConfigMap{ ObjectMeta: metav1.ObjectMeta{ - Namespace: "events-system", + Namespace: system.Namespace(), Name: configName, }, Data: map[string]string{