37 lines
1.1 KiB
Go
37 lines
1.1 KiB
Go
package multitenant
|
|
|
|
import (
|
|
"context"
|
|
"testing"
|
|
|
|
"go.uber.org/zap"
|
|
k8sfake "k8s.io/client-go/kubernetes/fake"
|
|
|
|
fv1 "github.com/fission/fission/pkg/apis/core/v1"
|
|
"github.com/fission/fission/pkg/executor/executortype"
|
|
"github.com/fission/fission/pkg/utils"
|
|
)
|
|
|
|
func TestNewNamespaceSubscriberAddAndResync(t *testing.T) {
|
|
poolmgr := &fakeExecutorType{}
|
|
subscriber := NewNamespaceSubscriber(zap.NewNop(), k8sfake.NewSimpleClientset(), map[fv1.ExecutorType]executortype.ExecutorType{
|
|
fv1.ExecutorTypePoolmgr: poolmgr,
|
|
}, nil)
|
|
record := utils.NamespaceRecord{Name: "tenant-executor-b"}
|
|
|
|
if subscriber.Name() != "executor" {
|
|
t.Fatalf("expected executor subscriber name")
|
|
}
|
|
if err := subscriber.OnNamespaceAdd(context.Background(), record); err != nil {
|
|
t.Fatalf("expected add to succeed: %v", err)
|
|
}
|
|
if err := subscriber.OnNamespaceResync(context.Background(), record); err != nil {
|
|
t.Fatalf("expected resync to succeed: %v", err)
|
|
}
|
|
if poolmgr.addCalls != 2 {
|
|
t.Fatalf("expected executor type to receive add and resync calls")
|
|
}
|
|
if poolmgr.lastNamespace != "tenant-executor-b" {
|
|
t.Fatalf("expected namespace to be forwarded to executor type")
|
|
}
|
|
} |