Files
tasks/service/worker/scanner/executions/task_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

73 lines
1.9 KiB
Go

package executions
import (
"context"
"errors"
"testing"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/suite"
"github.com/hanzoai/tasks/common/log"
"github.com/hanzoai/tasks/common/metrics"
"github.com/hanzoai/tasks/common/persistence"
"github.com/hanzoai/tasks/common/quotas"
"github.com/hanzoai/tasks/service/worker/scanner/executor"
"go.uber.org/mock/gomock"
)
type taskTestSuite struct {
suite.Suite
controller *gomock.Controller
executionManager *persistence.MockExecutionManager
rateLimiter *quotas.MockRateLimiter
}
func TestTaskTestSuite(t *testing.T) {
suite.Run(t, new(taskTestSuite))
}
func (s *taskTestSuite) SetupTest() {
s.controller = gomock.NewController(s.T())
s.executionManager = persistence.NewMockExecutionManager(s.controller)
s.rateLimiter = quotas.NewMockRateLimiter(s.controller)
}
func (s *taskTestSuite) TearDownTest() {
s.controller.Finish()
}
func (s *taskTestSuite) createTask() *task {
return &task{
shardID: 1,
executionManager: s.executionManager,
metricsHandler: metrics.NoopMetricsHandler,
logger: log.NewNoopLogger(),
scavenger: &Scavenger{numHistoryShards: 4},
ctx: context.Background(),
rateLimiter: s.rateLimiter,
}
}
func (s *taskTestSuite) TestRun_Success_EmptyResults() {
task := s.createTask()
s.executionManager.EXPECT().
ListConcreteExecutions(gomock.Any(), gomock.Any()).
Return(&persistence.ListConcreteExecutionsResponse{}, nil)
status := task.Run()
assert.Equal(s.T(), executor.TaskStatusDone, status)
}
func (s *taskTestSuite) TestRun_PaginationError() {
task := s.createTask()
s.rateLimiter.EXPECT().Wait(gomock.Any()).Return(nil)
s.executionManager.EXPECT().
ListConcreteExecutions(gomock.Any(), gomock.Any()).
Return(nil, errors.New("pagination error"))
status := task.Run()
assert.Equal(s.T(), executor.TaskStatusDefer, status)
}