(t *testing.T)
| 1597 | } |
| 1598 | |
| 1599 | func TestTaskMutationCommandsMapRequests(t *testing.T) { |
| 1600 | t.Parallel() |
| 1601 | |
| 1602 | tests := []struct { |
| 1603 | name string |
| 1604 | run func(t *testing.T) |
| 1605 | }{ |
| 1606 | { |
| 1607 | name: "Should parse task update request", |
| 1608 | run: func(t *testing.T) { |
| 1609 | t.Helper() |
| 1610 | |
| 1611 | var ( |
| 1612 | updateTaskID string |
| 1613 | updateRequest UpdateTaskRequest |
| 1614 | ) |
| 1615 | deps := newTestDeps(t, &stubClient{ |
| 1616 | updateTaskFn: func(_ context.Context, taskID string, request UpdateTaskRequest) (TaskRecord, error) { |
| 1617 | updateTaskID = taskID |
| 1618 | updateRequest = request |
| 1619 | return sampleTaskRecord(), nil |
| 1620 | }, |
| 1621 | }) |
| 1622 | |
| 1623 | if _, _, err := executeRootCommand( |
| 1624 | t, |
| 1625 | deps, |
| 1626 | "task", "update", "task-1", |
| 1627 | "--title", "Retitle triage task", |
| 1628 | "--description", "Refined scope", |
| 1629 | "--priority", "urgent", |
| 1630 | "--channel", "builders", |
| 1631 | "--owner-kind", "pool", |
| 1632 | "--owner-ref", "triage", |
| 1633 | "--metadata", `{"priority":"low"}`, |
| 1634 | "-o", "json", |
| 1635 | ); err != nil { |
| 1636 | t.Fatalf("task update error = %v", err) |
| 1637 | } |
| 1638 | if updateTaskID != "task-1" || |
| 1639 | updateRequest.Title == nil || *updateRequest.Title != "Retitle triage task" || |
| 1640 | updateRequest.Description == nil || *updateRequest.Description != "Refined scope" || |
| 1641 | updateRequest.Priority == nil || *updateRequest.Priority != taskpkg.PriorityUrgent || |
| 1642 | updateRequest.NetworkChannel == nil || *updateRequest.NetworkChannel != "builders" || |
| 1643 | updateRequest.Owner == nil || updateRequest.Owner.Kind != taskpkg.OwnerKindPool || updateRequest.Owner.Ref != "triage" || |
| 1644 | updateRequest.ClearOwner || |
| 1645 | updateRequest.Metadata == nil || string(*updateRequest.Metadata) != `{"priority":"low"}` { |
| 1646 | t.Fatalf("update request = %#v, want parsed task mutation payload", updateRequest) |
| 1647 | } |
| 1648 | }, |
| 1649 | }, |
| 1650 | { |
| 1651 | name: "Should parse task cancel request", |
| 1652 | run: func(t *testing.T) { |
| 1653 | t.Helper() |
| 1654 | |
| 1655 | var ( |
| 1656 | cancelTaskID string |
nothing calls this directly
no test coverage detected