MCPcopy Create free account
hub / github.com/compozy/agh / TestManagerTerminalRunStopsBackingSession

Function TestManagerTerminalRunStopsBackingSession

internal/task/manager_test.go:6079–6219  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

6077}
6078
6079func TestManagerTerminalRunStopsBackingSession(t *testing.T) {
6080 t.Parallel()
6081
6082 t.Run("Should stop completed run session", func(t *testing.T) {
6083 t.Parallel()
6084
6085 store := newInMemoryManagerStore()
6086 executor := &recordingSessionExecutor{}
6087 manager := newTaskManagerForTestWithOptions(
6088 t,
6089 store,
6090 WithSessionExecutor(executor),
6091 WithCancelGracePeriod(0),
6092 )
6093 actor := validActorContext()
6094 runningRun := createRunningRunForTest(t, manager, actor)
6095
6096 if _, err := manager.CompleteRun(context.Background(), runningRun.ID, RunResult{
6097 Value: json.RawMessage(`{"ok":true}`),
6098 }, actor); err != nil {
6099 t.Fatalf("CompleteRun() error = %v", err)
6100 }
6101
6102 assertSessionStopCalls(t, executor, runningRun.SessionID, StopReasonCompleted)
6103 })
6104
6105 t.Run("Should stop failed run session", func(t *testing.T) {
6106 t.Parallel()
6107
6108 store := newInMemoryManagerStore()
6109 executor := &recordingSessionExecutor{}
6110 manager := newTaskManagerForTestWithOptions(
6111 t,
6112 store,
6113 WithSessionExecutor(executor),
6114 WithCancelGracePeriod(0),
6115 )
6116 actor := validActorContext()
6117 runningRun := createRunningRunForTest(t, manager, actor)
6118
6119 if _, err := manager.FailRun(context.Background(), runningRun.ID, RunFailure{
6120 Error: "release validation failed",
6121 }, actor); err != nil {
6122 t.Fatalf("FailRun() error = %v", err)
6123 }
6124
6125 assertSessionStopCalls(t, executor, runningRun.SessionID, StopReasonFailed)
6126 })
6127
6128 t.Run("Should keep run non-terminal when completed stop request fails", func(t *testing.T) {
6129 t.Parallel()
6130
6131 assertTerminalStopFailureLeavesRunActive(t, errors.New("stop failed"), nil, func(
6132 ctx context.Context,
6133 manager *Service,
6134 runID string,
6135 actor ActorContext,
6136 ) error {

Callers

nothing calls this directly

Calls 12

newInMemoryManagerStoreFunction · 0.85
WithSessionExecutorFunction · 0.85
WithCancelGracePeriodFunction · 0.85
validActorContextFunction · 0.85
createRunningRunForTestFunction · 0.85
assertSessionStopCallsFunction · 0.85
RunMethod · 0.65
CompleteRunMethod · 0.65
FailRunMethod · 0.65
CancelRunMethod · 0.65

Tested by

no test coverage detected