feat(work): orchestrate dry-run dispatch persistence
This commit is contained in:
@@ -0,0 +1,40 @@
|
||||
package agent_execution_test
|
||||
|
||||
import (
|
||||
"context"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"git.cin.su/m/Assistant/contracts/work"
|
||||
"git.cin.su/m/Assistant/modules/work/application"
|
||||
)
|
||||
|
||||
type recordingExecutionStore struct {
|
||||
operations []string
|
||||
}
|
||||
|
||||
func (s *recordingExecutionStore) SaveDispatchIntent(context.Context, work.AgentDispatchIntent) error {
|
||||
s.operations = append(s.operations, "intent")
|
||||
return nil
|
||||
}
|
||||
func (s *recordingExecutionStore) SaveAgentLease(context.Context, work.AgentLease) error {
|
||||
s.operations = append(s.operations, "lease")
|
||||
return nil
|
||||
}
|
||||
func (s *recordingExecutionStore) AcceptAgentCallback(context.Context, work.AgentCallback) error {
|
||||
s.operations = append(s.operations, "callback")
|
||||
return nil
|
||||
}
|
||||
|
||||
func TestExecuteDryRunDispatchPersistsInOrder(t *testing.T) {
|
||||
now := time.UnixMilli(1_700_000_000_000)
|
||||
intent := work.AgentDispatchIntent{DispatchID: "dispatch-1", IdempotencyKey: "idem-1", DelegationID: "delegation-1", RunID: "run-1", ImplementationID: "fake-worker", ImplementationRevision: 1, SourceRevision: "source-1", WorktreeID: "worktree-1", VerificationPlanRef: "verify-1", CreatedAtUnixMillis: now.UnixMilli()}
|
||||
store := &recordingExecutionStore{}
|
||||
result, err := application.ExecuteDryRunDispatch(context.Background(), store, intent, "worker-1", 7, now, 15*time.Minute)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if result.CallbackCount() != 2 || len(store.operations) != 4 || store.operations[0] != "intent" || store.operations[1] != "lease" || store.operations[2] != "callback" || store.operations[3] != "callback" {
|
||||
t.Fatalf("unexpected persistence sequence: %#v", store.operations)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user