Skip to content

Commit

Permalink
Add unit tests for replication fetchers (#6015)
Browse files Browse the repository at this point in the history
  • Loading branch information
Shaddoll committed May 11, 2024
1 parent 957fd1a commit 8821ae9
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions service/history/replication/task_fetcher_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,15 @@ import (
"time"

"github.com/golang/mock/gomock"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"github.com/stretchr/testify/suite"
"go.uber.org/goleak"

"github.com/uber/cadence/client"
"github.com/uber/cadence/client/admin"
"github.com/uber/cadence/common/clock"
"github.com/uber/cadence/common/cluster"
"github.com/uber/cadence/common/dynamicconfig"
"github.com/uber/cadence/common/log/testlogger"
"github.com/uber/cadence/common/metrics"
Expand Down Expand Up @@ -252,3 +255,20 @@ func (s *taskFetcherSuite) TestLifecycle() {
s.False(open)
s.Equal(4, fetchAndDistributeTasksFnCall)
}

func TestTaskFetchers(t *testing.T) {
defer goleak.VerifyNone(t)
ctrl := gomock.NewController(t)
mockBean := client.NewMockBean(ctrl)
mockAdminClient := admin.NewMockClient(ctrl)
logger := testlogger.New(t)
cfg := config.NewForTest()

mockBean.EXPECT().GetRemoteAdminClient(cluster.TestAlternativeClusterName).Return(mockAdminClient)
fetchers := NewTaskFetchers(logger, cfg, cluster.TestActiveClusterMetadata, mockBean)
assert.NotNil(t, fetchers)
assert.Len(t, fetchers.GetFetchers(), len(cluster.TestActiveClusterMetadata.GetRemoteClusterInfo()))

fetchers.Start()
fetchers.Stop()
}

0 comments on commit 8821ae9

Please sign in to comment.