layer1: add namespace part helpers step 14

This commit is contained in:
Naeel
2026-04-26 10:05:12 +03:00
parent b3f99b2b6c
commit db4499d8c7
3 changed files with 64 additions and 2 deletions
+25 -1
View File
@@ -1,6 +1,7 @@
package utils
import (
"errors"
"reflect"
"testing"
"time"
@@ -159,6 +160,29 @@ func TestNamespaceManagerBootstrap(t *testing.T) {
}
}
func TestNamespaceManagerPartStateHelpers(t *testing.T) {
manager := NewNamespaceManager()
manager.Upsert(NamespaceEvent{Type: NamespaceEventAdd, Name: "tenant-a", Source: NamespaceSourceWatcher})
record, ok := manager.MarkPartRegistering("tenant-a", "router")
if !ok || record.Phase != NamespacePhaseRegistering {
t.Fatalf("expected registering helper to set registering phase")
}
record, ok = manager.MarkPartActive("tenant-a", "router")
if !ok || record.Phase != NamespacePhaseActive {
t.Fatalf("expected active helper to set active phase")
}
record, ok = manager.MarkPartFailed("tenant-a", "router", errors.New("boom"))
if !ok || record.Phase != NamespacePhaseFailed {
t.Fatalf("expected failed helper to set failed phase")
}
if record.RegisteredParts["router"].LastError != "boom" {
t.Fatalf("expected failed helper to persist error")
}
}
func TestNewBootstrappedNamespaceManager(t *testing.T) {
resolver := &NamespaceResolver{
FissionResourceNS: map[string]string{
@@ -178,4 +202,4 @@ func TestNewBootstrappedNamespaceManager(t *testing.T) {
if record.Source != NamespaceSourceEnv {
t.Fatalf("expected env source, got %s", record.Source)
}
}
}