layer1: add namespace part helpers step 14
This commit is contained in:
@@ -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)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user