layer1: add namespace event helpers step 15

This commit is contained in:
Naeel
2026-04-26 10:05:51 +03:00
parent db4499d8c7
commit 834c0de941
3 changed files with 55 additions and 2 deletions
+22 -1
View File
@@ -64,4 +64,25 @@ func TestNamespaceRecordIsTerminal(t *testing.T) {
t.Fatalf("expected terminal=%v for phase %s", test.expected, test.phase)
}
}
}
}
func TestNewNamespaceEventClonesLabels(t *testing.T) {
now := time.Now().UTC()
labels := map[string]string{ManagedNamespaceLabelKey: ManagedNamespaceLabelValue}
event := NewNamespaceEvent(NamespaceEventAdd, "tenant-a", labels, NamespaceSourceWatcher, now)
labels[ManagedNamespaceLabelKey] = "false"
if event.Labels[ManagedNamespaceLabelKey] != ManagedNamespaceLabelValue {
t.Fatalf("expected namespace event labels to be cloned")
}
}
func TestManagedNamespaceEvent(t *testing.T) {
event := ManagedNamespaceEvent(NamespaceEventAdd, "tenant-a", NamespaceSourceWatcher, time.Now().UTC())
if event.Labels[ManagedNamespaceLabelKey] != ManagedNamespaceLabelValue {
t.Fatalf("expected managed namespace label in event")
}
if event.Name != "tenant-a" {
t.Fatalf("expected tenant-a event name")
}
}