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).
82 lines
2.0 KiB
Go
82 lines
2.0 KiB
Go
package persistence
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/require"
|
|
"github.com/stretchr/testify/suite"
|
|
persistencespb "github.com/hanzoai/tasks/api/persistence/v1"
|
|
"github.com/hanzoai/tasks/common/persistence/serialization"
|
|
"github.com/hanzoai/tasks/common/primitives"
|
|
)
|
|
|
|
type (
|
|
historyBranchUtilSuite struct {
|
|
suite.Suite
|
|
*require.Assertions
|
|
}
|
|
)
|
|
|
|
func TestHistoryBranchUtilSuite(t *testing.T) {
|
|
s := new(historyBranchUtilSuite)
|
|
suite.Run(t, s)
|
|
}
|
|
|
|
func (s *historyBranchUtilSuite) SetupSuite() {
|
|
}
|
|
|
|
func (s *historyBranchUtilSuite) TearDownSuite() {
|
|
}
|
|
|
|
func (s *historyBranchUtilSuite) SetupTest() {
|
|
s.Assertions = require.New(s.T())
|
|
}
|
|
|
|
func (s *historyBranchUtilSuite) TearDownTest() {
|
|
}
|
|
|
|
func (s *historyBranchUtilSuite) TestHistoryBranchUtil() {
|
|
var historyBranchUtil HistoryBranchUtil = NewHistoryBranchUtil(serialization.NewSerializer())
|
|
|
|
treeID0 := primitives.NewUUID().String()
|
|
branchID0 := primitives.NewUUID().String()
|
|
ancestors := []*persistencespb.HistoryBranchRange(nil)
|
|
branchToken0, err := historyBranchUtil.NewHistoryBranch(
|
|
primitives.NewUUID().String(),
|
|
primitives.NewUUID().String(),
|
|
primitives.NewUUID().String(),
|
|
treeID0,
|
|
&branchID0,
|
|
ancestors,
|
|
0,
|
|
0,
|
|
0,
|
|
)
|
|
s.NoError(err)
|
|
|
|
branchInfo0, err := historyBranchUtil.ParseHistoryBranchInfo(branchToken0)
|
|
s.NoError(err)
|
|
s.Equal(treeID0, branchInfo0.TreeId)
|
|
s.Equal(branchID0, branchInfo0.BranchId)
|
|
s.Equal(ancestors, branchInfo0.Ancestors)
|
|
|
|
treeID1 := primitives.NewUUID().String()
|
|
branchID1 := primitives.NewUUID().String()
|
|
branchToken1, err := historyBranchUtil.UpdateHistoryBranchInfo(
|
|
branchToken0,
|
|
&persistencespb.HistoryBranch{
|
|
TreeId: treeID1,
|
|
BranchId: branchID1,
|
|
Ancestors: ancestors,
|
|
},
|
|
primitives.NewUUID().String(),
|
|
)
|
|
s.NoError(err)
|
|
|
|
branchInfo1, err := historyBranchUtil.ParseHistoryBranchInfo(branchToken1)
|
|
s.NoError(err)
|
|
s.Equal(treeID1, branchInfo1.TreeId)
|
|
s.Equal(branchID1, branchInfo1.BranchId)
|
|
s.Equal(ancestors, branchInfo1.Ancestors)
|
|
}
|