feat(task): 暴露任务取消控制状态

This commit is contained in:
chengcheng
2026-06-25 17:01:32 +08:00
parent 6089aa6085
commit f4e1db1279
4 changed files with 49 additions and 0 deletions
@@ -76,3 +76,26 @@ func TestTaskCancelUnavailableReportsSubmittedFromRemoteTaskID(t *testing.T) {
t.Fatalf("remote task id should report submitted: %+v", result)
}
}
func TestDescribeTaskCancellationReportsQueuedTaskAsCancellable(t *testing.T) {
result := DescribeTaskCancellation(store.GatewayTask{ID: "task-queued", Status: "queued"})
if result.TaskID != "task-queued" {
t.Fatalf("unexpected task id: %+v", result)
}
if result.Cancelled || !result.Cancellable || result.Submitted {
t.Fatalf("queued local task should be cancellable and not submitted: %+v", result)
}
}
func TestDescribeTaskCancellationReportsRemoteTaskAsSubmitted(t *testing.T) {
result := DescribeTaskCancellation(store.GatewayTask{
ID: "task-remote",
Status: "running",
RemoteTaskID: "remote-1",
})
if result.Cancelled || result.Cancellable || !result.Submitted {
t.Fatalf("remote task should be submitted and non-cancellable: %+v", result)
}
}