From f3cad7633b1df6b30fd94385d0fb0258a48cb472 Mon Sep 17 00:00:00 2001 From: xdlbdy Date: Sat, 25 Mar 2023 18:12:14 +0800 Subject: [PATCH] feat: fix ut error Signed-off-by: xdlbdy --- internal/controller/trigger/controller_test.go | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/internal/controller/trigger/controller_test.go b/internal/controller/trigger/controller_test.go index e09e0a6ca..bee225e98 100644 --- a/internal/controller/trigger/controller_test.go +++ b/internal/controller/trigger/controller_test.go @@ -24,6 +24,7 @@ import ( "github.com/golang/mock/gomock" . "github.com/smartystreets/goconvey/convey" + "github.com/vanus-labs/vanus/pkg/cluster" ctrlpb "github.com/vanus-labs/vanus/proto/pkg/controller" metapb "github.com/vanus-labs/vanus/proto/pkg/meta" @@ -121,10 +122,17 @@ func TestController_CreateSubscription(t *testing.T) { subManager := subscription.NewMockManager(mockCtrl) ctrl.subscriptionManager = subManager ctrl.scheduler = worker.NewSubscriptionScheduler(ctrl.workerManager, ctrl.subscriptionManager) - + mockCluster := cluster.NewMockCluster(mockCtrl) + ctrl.cl = mockCluster Convey("create subscription", func() { subManager.EXPECT().GetSubscriptionByName(gomock.Any(), gomock.Any(), gomock.Any()).AnyTimes().Return(nil) subManager.EXPECT().AddSubscription(gomock.Any(), gomock.Any()).AnyTimes().Return(nil) + mockNsSvc := cluster.NewMockNamespaceService(mockCtrl) + mockEbSvc := cluster.NewMockEventbusService(mockCtrl) + mockCluster.EXPECT().NamespaceService().AnyTimes().Return(mockNsSvc) + mockCluster.EXPECT().EventbusService().AnyTimes().Return(mockEbSvc) + mockNsSvc.EXPECT().GetNamespace(gomock.Any(), gomock.Any()).AnyTimes().Return(nil, nil) + mockEbSvc.EXPECT().GetEventbus(gomock.Any(), gomock.Any()).AnyTimes().Return(nil, nil) create := &ctrlpb.CreateSubscriptionRequest{ Subscription: &ctrlpb.SubscriptionRequest{ NamespaceId: vanus.NewTestID().Uint64(),