Files
tasks/chasm/lib/scheduler/util_test.go
Lina JodoinandGitHub 4c140933cf [Scheduled Actions] CHASM Scheduler (#8255)
## 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.
2025-09-02 19:50:45 +00:00

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)
}