mirror of
https://github.com/hanzoai/tasks.git
synced 2026-11-03 03:56:04 +00:00
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).
59 lines
1.7 KiB
Go
59 lines
1.7 KiB
Go
package queues
|
|
|
|
import (
|
|
"testing"
|
|
"time"
|
|
|
|
"github.com/stretchr/testify/require"
|
|
persistencespb "github.com/hanzoai/tasks/api/persistence/v1"
|
|
"github.com/hanzoai/tasks/common/definition"
|
|
"github.com/hanzoai/tasks/service/history/tasks"
|
|
)
|
|
|
|
func TestGrouperNamespaceID_Key(t *testing.T) {
|
|
g := GrouperNamespaceID{}
|
|
k := g.Key(tasks.NewFakeTask(definition.NewWorkflowKey("nid", "", ""), tasks.CategoryTransfer, time.Now()))
|
|
require.Equal(t, "nid", k)
|
|
}
|
|
|
|
func TestGrouperNamespaceID_Predicate(t *testing.T) {
|
|
g := GrouperNamespaceID{}
|
|
p := g.Predicate([]any{"n1", "n2"})
|
|
require.Equal(t, tasks.NewNamespacePredicate([]string{"n1", "n2"}), p)
|
|
}
|
|
|
|
func TestGrouperStateMachineNamespaceIDAndDestination_Key(t *testing.T) {
|
|
g := GrouperStateMachineNamespaceIDAndDestination{}
|
|
task := &tasks.StateMachineOutboundTask{
|
|
StateMachineTask: tasks.StateMachineTask{
|
|
WorkflowKey: definition.NewWorkflowKey("nid", "", ""),
|
|
Info: &persistencespb.StateMachineTaskInfo{
|
|
Type: "3",
|
|
},
|
|
},
|
|
Destination: "dest",
|
|
}
|
|
k := g.Key(task)
|
|
require.Equal(t, tasks.TaskGroupNamespaceIDAndDestination{
|
|
TaskGroup: "3",
|
|
NamespaceID: "nid",
|
|
Destination: "dest",
|
|
}, k)
|
|
}
|
|
|
|
func TestGrouperStateMachineNamespaceIDAndDestination_Predicate(t *testing.T) {
|
|
g := GrouperStateMachineNamespaceIDAndDestination{}
|
|
groups := []tasks.TaskGroupNamespaceIDAndDestination{
|
|
{TaskGroup: "1", NamespaceID: "n1", Destination: "d1"},
|
|
{TaskGroup: "2", NamespaceID: "n2", Destination: "d2"},
|
|
}
|
|
untypedGroups := []any{}
|
|
for _, g := range groups {
|
|
untypedGroups = append(untypedGroups, g)
|
|
}
|
|
p := g.Predicate(untypedGroups)
|
|
|
|
expected := tasks.NewOutboundTaskPredicate(groups)
|
|
require.Equal(t, expected, p)
|
|
}
|