Files
tasks/service/history/api/pauseactivity/api_test.go
zeekay 5a601d081b rebrand: go.temporal.io/server -> github.com/hanzoai/tasks
Full module path rebrand from Temporal to Hanzo Tasks:
- go.mod module: github.com/hanzoai/tasks
- All internal Go imports updated (1906 files)
- cmd/server renamed to cmd/tasksd
- Binary name: tasksd (was temporal-server)
- Docker images: hanzoai/tasks (was temporalio/server)
- README rewritten with Hanzo Tasks branding
- LLM.md created with integration notes
- Makefile, goreleaser, CI workflows updated
- go.temporal.io/sdk and go.temporal.io/api imports preserved (separate repos)

Fork of Temporal.io (MIT license).
2026-03-19 10:36:40 -07:00

119 lines
3.7 KiB
Go

package pauseactivity
import (
"testing"
"github.com/google/uuid"
"github.com/stretchr/testify/require"
"github.com/stretchr/testify/suite"
commonpb "go.temporal.io/api/common/v1"
historyspb "github.com/hanzoai/tasks/api/history/v1"
persistencespb "github.com/hanzoai/tasks/api/persistence/v1"
"github.com/hanzoai/tasks/common/cluster"
"github.com/hanzoai/tasks/common/log"
"github.com/hanzoai/tasks/common/namespace"
"github.com/hanzoai/tasks/common/persistence/versionhistory"
"github.com/hanzoai/tasks/service/history/api"
"github.com/hanzoai/tasks/service/history/events"
historyi "github.com/hanzoai/tasks/service/history/interfaces"
"github.com/hanzoai/tasks/service/history/shard"
"github.com/hanzoai/tasks/service/history/tests"
"github.com/hanzoai/tasks/service/history/workflow"
"go.uber.org/mock/gomock"
)
type (
pauseActivitySuite struct {
suite.Suite
*require.Assertions
controller *gomock.Controller
mockShard *shard.ContextTest
mockEventsCache *events.MockCache
mockNamespaceCache *namespace.MockRegistry
mockTaskGenerator *workflow.MockTaskGenerator
mockMutableState *historyi.MockMutableState
mockClusterMetadata *cluster.MockMetadata
executionInfo *persistencespb.WorkflowExecutionInfo
validator *api.CommandAttrValidator
logger log.Logger
}
)
func TestActivityOptionsSuite(t *testing.T) {
s := new(pauseActivitySuite)
suite.Run(t, s)
}
func (s *pauseActivitySuite) SetupSuite() {
}
func (s *pauseActivitySuite) TearDownSuite() {
}
func (s *pauseActivitySuite) SetupTest() {
s.Assertions = require.New(s.T())
s.controller = gomock.NewController(s.T())
s.mockTaskGenerator = workflow.NewMockTaskGenerator(s.controller)
s.mockMutableState = historyi.NewMockMutableState(s.controller)
s.mockShard = shard.NewTestContext(
s.controller,
&persistencespb.ShardInfo{
ShardId: 0,
RangeId: 1,
},
tests.NewDynamicConfig(),
)
s.mockNamespaceCache = s.mockShard.Resource.NamespaceCache
s.mockClusterMetadata = s.mockShard.Resource.ClusterMetadata
s.mockEventsCache = s.mockShard.MockEventsCache
s.mockClusterMetadata.EXPECT().GetCurrentClusterName().Return(cluster.TestCurrentClusterName).AnyTimes()
s.mockClusterMetadata.EXPECT().GetClusterID().Return(int64(1)).AnyTimes()
s.mockClusterMetadata.EXPECT().IsGlobalNamespaceEnabled().Return(true).AnyTimes()
s.mockEventsCache.EXPECT().PutEvent(gomock.Any(), gomock.Any()).AnyTimes()
s.logger = s.mockShard.GetLogger()
s.executionInfo = &persistencespb.WorkflowExecutionInfo{
VersionHistories: versionhistory.NewVersionHistories(&historyspb.VersionHistory{}),
FirstExecutionRunId: uuid.NewString(),
WorkflowExecutionTimerTaskStatus: workflow.TimerTaskStatusCreated,
}
s.mockMutableState.EXPECT().GetExecutionInfo().Return(s.executionInfo).AnyTimes()
s.mockMutableState.EXPECT().GetCurrentVersion().Return(int64(1)).AnyTimes()
s.validator = api.NewCommandAttrValidator(
s.mockShard.GetNamespaceRegistry(),
s.mockShard.GetConfig(),
nil,
)
}
func (s *pauseActivitySuite) TearDownTest() {
s.controller.Finish()
s.mockShard.StopForTest()
}
func (s *pauseActivitySuite) TestPauseActivityAcceptance() {
activityId := "activity_id"
activityInfo := &persistencespb.ActivityInfo{
TaskQueue: "task_queue_name",
ActivityId: activityId,
ActivityType: &commonpb.ActivityType{
Name: "activity_type",
},
}
s.mockMutableState.EXPECT().IsWorkflowExecutionRunning().Return(true)
s.mockMutableState.EXPECT().GetActivityByActivityID(gomock.Any()).Return(activityInfo, true)
s.mockMutableState.EXPECT().UpdateActivity(gomock.Any(), gomock.Any())
err := workflow.PauseActivity(s.mockMutableState, activityId, nil)
s.NoError(err)
}