mirror of
https://github.com/hanzoai/tasks.git
synced 2026-10-04 02:04:03 +00:00
## What changed? - Merge PR combining the previous PRs: #8164, #8165, #8166, #8167, #8168, #8169 ## Why? - All of those PRs are interdependent and cannot be merged individually cleanly. Sending a single merge commit PR to be merged to main. ## How did you test it? - [ ] built - [ ] run locally and tested manually - [ ] covered by existing tests - [ ] added new unit test(s) - [ ] added new functional test(s) ## Potential risks - It's still disabled.
52 lines
992 B
Go
52 lines
992 B
Go
package scheduler
|
|
|
|
import (
|
|
"fmt"
|
|
"testing"
|
|
"time"
|
|
|
|
"github.com/stretchr/testify/require"
|
|
schedulespb "go.temporal.io/server/chasm/lib/scheduler/gen/schedulerpb/v1"
|
|
)
|
|
|
|
func TestGenerateRequestID(t *testing.T) {
|
|
scheduler := &Scheduler{
|
|
SchedulerState: &schedulespb.SchedulerState{
|
|
Namespace: "ns",
|
|
NamespaceId: "nsid",
|
|
ScheduleId: "mysched",
|
|
ConflictToken: 10,
|
|
},
|
|
}
|
|
nominalTime := time.Now()
|
|
actualTime := time.Now()
|
|
|
|
// No backfill ID given.
|
|
actual := generateRequestID(
|
|
scheduler,
|
|
"",
|
|
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(
|
|
scheduler,
|
|
"backfillid",
|
|
nominalTime,
|
|
actualTime,
|
|
)
|
|
expected = fmt.Sprintf(
|
|
"sched-backfillid-nsid-mysched-10-%d-%d",
|
|
nominalTime.UnixMilli(),
|
|
actualTime.UnixMilli(),
|
|
)
|
|
require.Equal(t, expected, actual)
|
|
}
|