github-issue-201-completetask-completed-tasks-yaml (#202)

* fix: stable release時にnext dist-tagを自動同期

* takt: github-issue-201-completetask-completed-tasks-yaml
This commit is contained in:
nrs 2026-02-10 13:37:33 +09:00 committed by GitHub
parent 7e15691ba2
commit 6b207e0c74
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 24 additions and 12 deletions

View File

@ -180,7 +180,7 @@ describe('TaskRunner (tasks.yaml)', () => {
expect(() => runner.listTasks()).toThrow(/ENOENT|no such file/i); expect(() => runner.listTasks()).toThrow(/ENOENT|no such file/i);
}); });
it('should mark claimed task as completed', () => { it('should remove completed task record from tasks.yaml', () => {
runner.addTask('Task A'); runner.addTask('Task A');
const task = runner.claimNextTasks(1)[0]!; const task = runner.claimNextTasks(1)[0]!;
@ -194,7 +194,27 @@ describe('TaskRunner (tasks.yaml)', () => {
}); });
const file = loadTasksFile(testDir); const file = loadTasksFile(testDir);
expect(file.tasks[0]?.status).toBe('completed'); expect(file.tasks).toHaveLength(0);
});
it('should remove only the completed task when multiple tasks exist', () => {
runner.addTask('Task A');
runner.addTask('Task B');
const task = runner.claimNextTasks(1)[0]!;
runner.completeTask({
task,
success: true,
response: 'Done',
executionLog: [],
startedAt: new Date().toISOString(),
completedAt: new Date().toISOString(),
});
const file = loadTasksFile(testDir);
expect(file.tasks).toHaveLength(1);
expect(file.tasks[0]?.name).toContain('task-b');
expect(file.tasks[0]?.status).toBe('pending');
}); });
it('should mark claimed task as failed with failure detail', () => { it('should mark claimed task as failed with failure detail', () => {

View File

@ -119,17 +119,9 @@ export class TaskRunner {
throw new Error(`Task not found: ${result.task.name}`); throw new Error(`Task not found: ${result.task.name}`);
} }
const target = current.tasks[index]!; return {
const updated: TaskRecord = { tasks: current.tasks.filter((_, i) => i !== index),
...target,
status: 'completed',
completed_at: result.completedAt,
owner_pid: null,
failure: undefined,
}; };
const tasks = [...current.tasks];
tasks[index] = updated;
return { tasks };
}); });
return this.tasksFile; return this.tasksFile;