mirror of
https://github.com/hanzoai/tasks.git
synced 2026-11-03 03:56:04 +00:00
## What changed? Added proto definitions and conversion functions for V1 to V2 schedule migration. ## Why? This is the foundation for the V1→V2 schedule migration feature. The `MigrateScheduleRequest` proto captures all scheduler state needed to recreate a schedule in the CHASM architecture.
55 lines
1.0 KiB
Go
55 lines
1.0 KiB
Go
package schedules
|
|
|
|
import (
|
|
"fmt"
|
|
"testing"
|
|
"time"
|
|
|
|
"github.com/stretchr/testify/require"
|
|
)
|
|
|
|
func TestGenerateWorkflowID(t *testing.T) {
|
|
baseWorkflowID := "my-workflow"
|
|
nominalTime := time.Date(2024, 6, 15, 10, 30, 45, 123456789, time.UTC)
|
|
|
|
actual := GenerateWorkflowID(baseWorkflowID, nominalTime)
|
|
require.Equal(t, "my-workflow-2024-06-15T10:30:45Z", actual)
|
|
}
|
|
|
|
func TestGenerateRequestID(t *testing.T) {
|
|
nominalTime := time.Now()
|
|
actualTime := time.Now()
|
|
|
|
// No backfill ID given.
|
|
actual := GenerateRequestID(
|
|
"nsid",
|
|
"mysched",
|
|
10,
|
|
"",
|
|
nominalTime,
|
|
actualTime,
|
|
)
|
|
expected := fmt.Sprintf(
|
|
"sched-auto-nsid-mysched-10-%d-%d",
|
|
nominalTime.UnixMilli(),
|
|
actualTime.UnixMilli(),
|
|
)
|
|
require.Equal(t, expected, actual)
|
|
|
|
// Backfill ID given.
|
|
actual = GenerateRequestID(
|
|
"nsid",
|
|
"mysched",
|
|
10,
|
|
"backfillid",
|
|
nominalTime,
|
|
actualTime,
|
|
)
|
|
expected = fmt.Sprintf(
|
|
"sched-backfillid-nsid-mysched-10-%d-%d",
|
|
nominalTime.UnixMilli(),
|
|
actualTime.UnixMilli(),
|
|
)
|
|
require.Equal(t, expected, actual)
|
|
}
|