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).
68 lines
2.1 KiB
Go
68 lines
2.1 KiB
Go
package common
|
|
|
|
import (
|
|
"strconv"
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/require"
|
|
commonpb "go.temporal.io/api/common/v1"
|
|
workflowpb "go.temporal.io/api/workflow/v1"
|
|
"github.com/hanzoai/tasks/chasm"
|
|
"github.com/hanzoai/tasks/common/payload"
|
|
"github.com/hanzoai/tasks/common/searchattribute/sadefs"
|
|
)
|
|
|
|
func TestArchetypeIDFromExecutionInfo(t *testing.T) {
|
|
t.Run("NoSearchAttributes", func(t *testing.T) {
|
|
execInfo := &workflowpb.WorkflowExecutionInfo{}
|
|
id, err := ArchetypeIDFromExecutionInfo(execInfo)
|
|
require.NoError(t, err)
|
|
require.Equal(t, chasm.WorkflowArchetypeID, id)
|
|
})
|
|
|
|
t.Run("NoNamespaceDivision", func(t *testing.T) {
|
|
execInfo := &workflowpb.WorkflowExecutionInfo{
|
|
SearchAttributes: &commonpb.SearchAttributes{IndexedFields: map[string]*commonpb.Payload{}},
|
|
}
|
|
id, err := ArchetypeIDFromExecutionInfo(execInfo)
|
|
require.NoError(t, err)
|
|
require.Equal(t, chasm.WorkflowArchetypeID, id)
|
|
})
|
|
|
|
t.Run("Scheduler", func(t *testing.T) {
|
|
p := payload.EncodeString("TemporalScheduler")
|
|
execInfo := &workflowpb.WorkflowExecutionInfo{
|
|
SearchAttributes: &commonpb.SearchAttributes{IndexedFields: map[string]*commonpb.Payload{
|
|
sadefs.TemporalNamespaceDivision: p,
|
|
}},
|
|
}
|
|
id, err := ArchetypeIDFromExecutionInfo(execInfo)
|
|
require.NoError(t, err)
|
|
require.Equal(t, chasm.WorkflowArchetypeID, id)
|
|
})
|
|
|
|
t.Run("CHASM", func(t *testing.T) {
|
|
p := payload.EncodeString(strconv.FormatUint(42, 10))
|
|
execInfo := &workflowpb.WorkflowExecutionInfo{
|
|
SearchAttributes: &commonpb.SearchAttributes{IndexedFields: map[string]*commonpb.Payload{
|
|
sadefs.TemporalNamespaceDivision: p,
|
|
}},
|
|
}
|
|
id, err := ArchetypeIDFromExecutionInfo(execInfo)
|
|
require.NoError(t, err)
|
|
require.Equal(t, chasm.ArchetypeID(42), id)
|
|
})
|
|
|
|
t.Run("ErrorOnInvalidNumber", func(t *testing.T) {
|
|
p := payload.EncodeString("1x")
|
|
|
|
execInfo := &workflowpb.WorkflowExecutionInfo{
|
|
SearchAttributes: &commonpb.SearchAttributes{IndexedFields: map[string]*commonpb.Payload{
|
|
sadefs.TemporalNamespaceDivision: p,
|
|
}},
|
|
}
|
|
_, err := ArchetypeIDFromExecutionInfo(execInfo)
|
|
require.Error(t, err)
|
|
})
|
|
}
|