layer1: add namespace subscriber adapter step 19
This commit is contained in:
@@ -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")
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user