Skip to content

Commit f3cad76

Browse files
committed
feat: fix ut error
Signed-off-by: xdlbdy <[email protected]>
1 parent 466e91a commit f3cad76

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

internal/controller/trigger/controller_test.go

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ import (
2424
"github.com/golang/mock/gomock"
2525
. "github.com/smartystreets/goconvey/convey"
2626

27+
"github.com/vanus-labs/vanus/pkg/cluster"
2728
ctrlpb "github.com/vanus-labs/vanus/proto/pkg/controller"
2829
metapb "github.com/vanus-labs/vanus/proto/pkg/meta"
2930

@@ -121,10 +122,17 @@ func TestController_CreateSubscription(t *testing.T) {
121122
subManager := subscription.NewMockManager(mockCtrl)
122123
ctrl.subscriptionManager = subManager
123124
ctrl.scheduler = worker.NewSubscriptionScheduler(ctrl.workerManager, ctrl.subscriptionManager)
124-
125+
mockCluster := cluster.NewMockCluster(mockCtrl)
126+
ctrl.cl = mockCluster
125127
Convey("create subscription", func() {
126128
subManager.EXPECT().GetSubscriptionByName(gomock.Any(), gomock.Any(), gomock.Any()).AnyTimes().Return(nil)
127129
subManager.EXPECT().AddSubscription(gomock.Any(), gomock.Any()).AnyTimes().Return(nil)
130+
mockNsSvc := cluster.NewMockNamespaceService(mockCtrl)
131+
mockEbSvc := cluster.NewMockEventbusService(mockCtrl)
132+
mockCluster.EXPECT().NamespaceService().AnyTimes().Return(mockNsSvc)
133+
mockCluster.EXPECT().EventbusService().AnyTimes().Return(mockEbSvc)
134+
mockNsSvc.EXPECT().GetNamespace(gomock.Any(), gomock.Any()).AnyTimes().Return(nil, nil)
135+
mockEbSvc.EXPECT().GetEventbus(gomock.Any(), gomock.Any()).AnyTimes().Return(nil, nil)
128136
create := &ctrlpb.CreateSubscriptionRequest{
129137
Subscription: &ctrlpb.SubscriptionRequest{
130138
NamespaceId: vanus.NewTestID().Uint64(),

0 commit comments

Comments
 (0)