layer1: add namespace event bridge step 18
This commit is contained in:
@@ -3,6 +3,8 @@ package utils
|
||||
import (
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
corev1 "k8s.io/api/core/v1"
|
||||
)
|
||||
|
||||
func TestNamespaceRecordClone(t *testing.T) {
|
||||
@@ -86,3 +88,22 @@ func TestManagedNamespaceEvent(t *testing.T) {
|
||||
t.Fatalf("expected tenant-a event name")
|
||||
}
|
||||
}
|
||||
|
||||
func TestNamespaceEventFromNamespace(t *testing.T) {
|
||||
namespace := &corev1.Namespace{}
|
||||
namespace.Name = "tenant-a"
|
||||
namespace.Labels = map[string]string{ManagedNamespaceLabelKey: ManagedNamespaceLabelValue}
|
||||
|
||||
event := NamespaceEventFromNamespace(NamespaceEventAdd, namespace, NamespaceSourceWatcher, time.Now().UTC())
|
||||
if event.Name != "tenant-a" {
|
||||
t.Fatalf("expected tenant-a event name")
|
||||
}
|
||||
if event.Labels[ManagedNamespaceLabelKey] != ManagedNamespaceLabelValue {
|
||||
t.Fatalf("expected namespace labels to be copied into event")
|
||||
}
|
||||
|
||||
namespace.Labels[ManagedNamespaceLabelKey] = "false"
|
||||
if event.Labels[ManagedNamespaceLabelKey] != ManagedNamespaceLabelValue {
|
||||
t.Fatalf("expected event labels to stay detached from original namespace")
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user