Skip to content

Commit

Permalink
Removed replication mocks (cadence-workflow#4883)
Browse files Browse the repository at this point in the history
* Removed replication mocks

* Ensure fakeTaskExecutor was called
  • Loading branch information
vytautas-karpavicius authored Jul 5, 2022
1 parent ac10760 commit 354e6b0
Show file tree
Hide file tree
Showing 12 changed files with 40 additions and 592 deletions.
2 changes: 0 additions & 2 deletions service/history/replication/dlq_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.

//go:generate mockgen -package $GOPACKAGE -source $GOFILE -destination dlq_handler_mock.go

package replication

import (
Expand Down
143 changes: 0 additions & 143 deletions service/history/replication/dlq_handler_mock.go

This file was deleted.

18 changes: 15 additions & 3 deletions service/history/replication/dlq_handler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ type (
adminClient *admin.MockClient
executionManager *mocks.ExecutionManager
shardManager *mocks.ShardManager
taskExecutor *MockTaskExecutor
taskExecutor *fakeTaskExecutor
taskExecutors map[string]TaskExecutor
sourceCluster string

Expand Down Expand Up @@ -94,7 +94,7 @@ func (s *dlqHandlerSuite) SetupTest() {
s.shardManager = s.mockShard.Resource.ShardMgr

s.taskExecutors = make(map[string]TaskExecutor)
s.taskExecutor = NewMockTaskExecutor(s.controller)
s.taskExecutor = &fakeTaskExecutor{}
s.sourceCluster = "test"
s.taskExecutors[s.sourceCluster] = s.taskExecutor

Expand Down Expand Up @@ -208,7 +208,6 @@ func (s *dlqHandlerSuite) TestMergeMessages_OK() {
Return(&types.GetDLQReplicationMessagesResponse{
ReplicationTasks: []*types.ReplicationTask{replicationTask},
}, nil)
s.taskExecutor.EXPECT().execute(replicationTask, true).Return(0, nil).Times(1)
s.executionManager.On("RangeDeleteReplicationTaskFromDLQ", mock.Anything,
&persistence.RangeDeleteReplicationTaskFromDLQRequest{
SourceClusterName: s.sourceCluster,
Expand All @@ -219,4 +218,17 @@ func (s *dlqHandlerSuite) TestMergeMessages_OK() {
token, err := s.messageHandler.MergeMessages(ctx, s.sourceCluster, lastMessageID, pageSize, pageToken)
s.NoError(err)
s.Nil(token)
s.Equal(1, len(s.taskExecutor.executedTasks))
}

type fakeTaskExecutor struct {
scope int
err error

executedTasks []*types.ReplicationTask
}

func (e *fakeTaskExecutor) execute(replicationTask *types.ReplicationTask, forceApply bool) (int, error) {
e.executedTasks = append(e.executedTasks, replicationTask)
return e.scope, e.err
}
2 changes: 0 additions & 2 deletions service/history/replication/task_ack_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.

//go:generate mockgen -package $GOPACKAGE -source $GOFILE -destination task_ack_manager_mock.go

package replication

import (
Expand Down
88 changes: 0 additions & 88 deletions service/history/replication/task_ack_manager_mock.go

This file was deleted.

2 changes: 0 additions & 2 deletions service/history/replication/task_executor.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.

//go:generate mockgen -package $GOPACKAGE -source $GOFILE -destination task_executor_mock.go

package replication

import (
Expand Down
72 changes: 0 additions & 72 deletions service/history/replication/task_executor_mock.go

This file was deleted.

2 changes: 0 additions & 2 deletions service/history/replication/task_fetcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.

//go:generate mockgen -package $GOPACKAGE -source $GOFILE -destination task_fetcher_mock.go -self_package github.com/uber/cadence/service/history/replication

package replication

import (
Expand Down
Loading

0 comments on commit 354e6b0

Please sign in to comment.