(t *testing.T)
| 5144 | } |
| 5145 | |
| 5146 | func TestManagerTaskBlockBreakerCanBeDisabled(t *testing.T) { |
| 5147 | t.Run( |
| 5148 | "Should keep recurrence accounting but skip escalation when disabled", |
| 5149 | func(t *testing.T) { |
| 5150 | t.Parallel() |
| 5151 | |
| 5152 | store := newInMemoryManagerStore() |
| 5153 | manager := newTaskManagerForTestWithOptions(t, store, WithBlockRecurrenceLimit(0)) |
| 5154 | actor := validActorContext() |
| 5155 | taskRecord, err := manager.CreateTask(context.Background(), CreateTask{ |
| 5156 | Scope: ScopeWorkspace, |
| 5157 | WorkspaceID: "ws-block-breaker-disabled", |
| 5158 | Title: "Breaker disabled", |
| 5159 | }, actor) |
| 5160 | if err != nil { |
| 5161 | t.Fatalf("CreateTask() error = %v", err) |
| 5162 | } |
| 5163 | |
| 5164 | for idx := range 3 { |
| 5165 | block, err := manager.BlockTask(context.Background(), BlockRequest{ |
| 5166 | TaskID: taskRecord.ID, |
| 5167 | Kind: BlockKindCapability, |
| 5168 | Reason: fmt.Sprintf("missing capability %d", idx), |
| 5169 | }, actor) |
| 5170 | if err != nil { |
| 5171 | t.Fatalf("BlockTask(%d) error = %v", idx, err) |
| 5172 | } |
| 5173 | if idx < 2 { |
| 5174 | if _, err := manager.ClearTaskBlock( |
| 5175 | context.Background(), |
| 5176 | taskRecord.ID, |
| 5177 | block.ID, |
| 5178 | "capability restored", |
| 5179 | actor, |
| 5180 | ); err != nil { |
| 5181 | t.Fatalf("ClearTaskBlock(%d) error = %v", idx, err) |
| 5182 | } |
| 5183 | } |
| 5184 | } |
| 5185 | if got, want := store.blockRecurrences[blockRecurrenceTestKey(taskRecord.ID, BlockKindCapability)].Count, 2; got != want { |
| 5186 | t.Fatalf("recurrence count = %d, want %d", got, want) |
| 5187 | } |
| 5188 | if store.tasks[taskRecord.ID].NeedsAttention != nil { |
| 5189 | t.Fatalf( |
| 5190 | "NeedsAttention = %#v, want disabled breaker to skip escalation", |
| 5191 | store.tasks[taskRecord.ID].NeedsAttention, |
| 5192 | ) |
| 5193 | } |
| 5194 | }, |
| 5195 | ) |
| 5196 | } |
| 5197 | |
| 5198 | func TestManagerExpireTaskBlocksDoesNotIncrementRecurrenceOnClear(t *testing.T) { |
| 5199 | t.Run( |
nothing calls this directly
no test coverage detected