Files
tasks/service/worker/scheduler/activities_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

67 lines
1.9 KiB
Go

package scheduler
import (
"context"
"errors"
"testing"
"github.com/stretchr/testify/require"
"go.temporal.io/api/serviceerror"
schedulerpb "github.com/hanzoai/tasks/chasm/lib/scheduler/gen/schedulerpb/v1"
"github.com/hanzoai/tasks/common/log"
"github.com/hanzoai/tasks/common/metrics"
"google.golang.org/grpc"
)
type mockSchedulerClient struct {
schedulerpb.SchedulerServiceClient
migrateErr error
}
func (m *mockSchedulerClient) CreateFromMigrationState(
_ context.Context,
_ *schedulerpb.CreateFromMigrationStateRequest,
_ ...grpc.CallOption,
) (*schedulerpb.CreateFromMigrationStateResponse, error) {
return &schedulerpb.CreateFromMigrationStateResponse{}, m.migrateErr
}
func newTestActivities(client schedulerpb.SchedulerServiceClient) *activities {
return &activities{
activityDeps: activityDeps{
Logger: log.NewNoopLogger(),
SchedulerClient: client,
MetricsHandler: metrics.NoopMetricsHandler,
},
}
}
func TestMigrateScheduleToChasm_Success(t *testing.T) {
client := &mockSchedulerClient{}
a := newTestActivities(client)
err := a.MigrateScheduleToChasm(context.Background(), &schedulerpb.CreateFromMigrationStateRequest{})
require.NoError(t, err)
}
func TestMigrateScheduleToChasm_AlreadyExists(t *testing.T) {
client := &mockSchedulerClient{
migrateErr: serviceerror.NewAlreadyExistsf("schedule %q is already registered", "test-schedule"),
}
a := newTestActivities(client)
err := a.MigrateScheduleToChasm(context.Background(), &schedulerpb.CreateFromMigrationStateRequest{})
require.NoError(t, err, "already-exists should be treated as success")
}
func TestMigrateScheduleToChasm_OtherError(t *testing.T) {
client := &mockSchedulerClient{
migrateErr: errors.New("some transient error"),
}
a := newTestActivities(client)
err := a.MigrateScheduleToChasm(context.Background(), &schedulerpb.CreateFromMigrationStateRequest{})
require.Error(t, err)
require.Contains(t, err.Error(), "MigrateScheduleToChasm")
}