layer1: add namespace subscriber adapter step 19

This commit is contained in:
Naeel
2026-04-26 10:24:01 +03:00
parent 022960ade7
commit bcf34d6b1a
3 changed files with 80 additions and 0 deletions
+32
View File
@@ -265,3 +265,35 @@ func TestNamespaceManagerDispatchResyncFailure(t *testing.T) {
t.Fatalf("expected subscriber error to be stored")
}
}
func TestNamespaceSubscriberFuncs(t *testing.T) {
addCalls := 0
removeCalls := 0
resyncCalls := 0
subscriber := NamespaceSubscriberFuncs{
SubscriberName: "router",
AddFunc: func(ctx context.Context, record NamespaceRecord) error {
addCalls++
return nil
},
RemoveFunc: func(ctx context.Context, record NamespaceRecord) error {
removeCalls++
return nil
},
ResyncFunc: func(ctx context.Context, record NamespaceRecord) error {
resyncCalls++
return nil
},
}
if subscriber.Name() != "router" {
t.Fatalf("expected subscriber name router")
}
_ = subscriber.OnNamespaceAdd(context.Background(), NamespaceRecord{Name: "tenant-a"})
_ = subscriber.OnNamespaceRemove(context.Background(), NamespaceRecord{Name: "tenant-a"})
_ = subscriber.OnNamespaceResync(context.Background(), NamespaceRecord{Name: "tenant-a"})
if addCalls != 1 || removeCalls != 1 || resyncCalls != 1 {
t.Fatalf("expected all functional callbacks to run once")
}
}