(t *testing.T)
| 4907 | } |
| 4908 | |
| 4909 | func TestManagerTaskBlockBreakerEscalatesAtLimit(t *testing.T) { |
| 4910 | t.Run( |
| 4911 | "Should escalate at the recurrence limit exactly once while already escalated", |
| 4912 | func(t *testing.T) { |
| 4913 | t.Parallel() |
| 4914 | |
| 4915 | store := newInMemoryManagerStore() |
| 4916 | needsAttentionHooks := 0 |
| 4917 | manager := newTaskManagerForTestWithOptions( |
| 4918 | t, |
| 4919 | store, |
| 4920 | WithTaskRunHooks(recordingTaskRunHooks{ |
| 4921 | needsAttention: func( |
| 4922 | _ context.Context, |
| 4923 | payload hookspkg.TaskNeedsAttentionPayload, |
| 4924 | ) (hookspkg.TaskNeedsAttentionPayload, error) { |
| 4925 | needsAttentionHooks++ |
| 4926 | return payload, nil |
| 4927 | }, |
| 4928 | }), |
| 4929 | ) |
| 4930 | actor := validActorContext() |
| 4931 | taskRecord, err := manager.CreateTask(context.Background(), CreateTask{ |
| 4932 | Scope: ScopeWorkspace, |
| 4933 | WorkspaceID: "ws-block-breaker", |
| 4934 | Title: "Breaker target", |
| 4935 | }, actor) |
| 4936 | if err != nil { |
| 4937 | t.Fatalf("CreateTask() error = %v", err) |
| 4938 | } |
| 4939 | |
| 4940 | first, err := manager.BlockTask(context.Background(), BlockRequest{ |
| 4941 | TaskID: taskRecord.ID, |
| 4942 | Kind: BlockKindNeedsInput, |
| 4943 | Reason: "waiting for creator", |
| 4944 | }, actor) |
| 4945 | if err != nil { |
| 4946 | t.Fatalf("BlockTask(first) error = %v", err) |
| 4947 | } |
| 4948 | if got, want := store.blockRecurrences[blockRecurrenceTestKey(taskRecord.ID, BlockKindNeedsInput)].Count, 0; got != want { |
| 4949 | t.Fatalf("first recurrence count = %d, want %d", got, want) |
| 4950 | } |
| 4951 | if _, err := manager.ClearTaskBlock( |
| 4952 | context.Background(), |
| 4953 | taskRecord.ID, |
| 4954 | first.ID, |
| 4955 | "resolved once", |
| 4956 | actor, |
| 4957 | ); err != nil { |
| 4958 | t.Fatalf("ClearTaskBlock(first) error = %v", err) |
| 4959 | } |
| 4960 | |
| 4961 | second, err := manager.BlockTask(context.Background(), BlockRequest{ |
| 4962 | TaskID: taskRecord.ID, |
| 4963 | Kind: BlockKindNeedsInput, |
| 4964 | Reason: "waiting again", |
| 4965 | }, actor) |
| 4966 | if err != nil { |
nothing calls this directly
no test coverage detected