(t *testing.T)
| 4549 | } |
| 4550 | |
| 4551 | func TestManagerBlockTaskServiceValidation(t *testing.T) { |
| 4552 | t.Parallel() |
| 4553 | |
| 4554 | t.Run( |
| 4555 | "Should reject empty reason and unsupported kind before inserting a block", |
| 4556 | func(t *testing.T) { |
| 4557 | t.Parallel() |
| 4558 | |
| 4559 | tests := []struct { |
| 4560 | name string |
| 4561 | req func(taskID string) BlockRequest |
| 4562 | }{ |
| 4563 | { |
| 4564 | name: "empty reason", |
| 4565 | req: func(taskID string) BlockRequest { |
| 4566 | return BlockRequest{TaskID: taskID, Kind: BlockKindNeedsInput, Reason: " "} |
| 4567 | }, |
| 4568 | }, |
| 4569 | { |
| 4570 | name: "unsupported kind", |
| 4571 | req: func(taskID string) BlockRequest { |
| 4572 | return BlockRequest{ |
| 4573 | TaskID: taskID, |
| 4574 | Kind: BlockKind("operator"), |
| 4575 | Reason: "waiting", |
| 4576 | } |
| 4577 | }, |
| 4578 | }, |
| 4579 | } |
| 4580 | |
| 4581 | for _, tt := range tests { |
| 4582 | t.Run(tt.name, func(t *testing.T) { |
| 4583 | t.Parallel() |
| 4584 | |
| 4585 | store := newInMemoryManagerStore() |
| 4586 | manager := newTaskManagerForTest(t, store) |
| 4587 | actor := validActorContext() |
| 4588 | taskRecord, err := manager.CreateTask(context.Background(), CreateTask{ |
| 4589 | Scope: ScopeWorkspace, |
| 4590 | WorkspaceID: "ws-block-validation-" + strings.ReplaceAll(tt.name, " ", "-"), |
| 4591 | Title: "Block validation", |
| 4592 | }, actor) |
| 4593 | if err != nil { |
| 4594 | t.Fatalf("CreateTask() error = %v", err) |
| 4595 | } |
| 4596 | |
| 4597 | if _, err := manager.BlockTask( |
| 4598 | context.Background(), |
| 4599 | tt.req(taskRecord.ID), |
| 4600 | actor, |
| 4601 | ); !errors.Is(err, ErrValidation) { |
| 4602 | t.Fatalf("BlockTask() error = %v, want %v", err, ErrValidation) |
| 4603 | } |
| 4604 | blocks, err := manager.ListTaskBlocks( |
| 4605 | context.Background(), |
| 4606 | taskRecord.ID, |
| 4607 | true, |
| 4608 | actor, |
nothing calls this directly
no test coverage detected