refactor: harden diagnostics and consolidate runtime code
This commit is contained in:
@@ -227,6 +227,29 @@ func TestTaskArtifactsDirStartsWithTaskNumber(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestFinalizeTaskArtifactPathsKeepsSourceWhenDestinationExists(t *testing.T) {
|
||||
logsDir := t.TempDir()
|
||||
sourceDir := filepath.Join(logsDir, "running-artifacts")
|
||||
if err := os.Mkdir(sourceDir, 0755); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
task := &Task{ID: "TASK-007", Name: "NVIDIA Benchmark", Status: TaskDone, ArtifactsDir: sourceDir}
|
||||
destinationDir := taskArtifactsDir(logsDir, task, TaskDone)
|
||||
if err := os.Mkdir(destinationDir, 0755); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
q := &taskQueue{logsDir: logsDir}
|
||||
q.finalizeTaskArtifactPathsLocked(task)
|
||||
|
||||
if task.ArtifactsDir != sourceDir {
|
||||
t.Fatalf("artifacts dir = %q, want retained source %q after destination collision", task.ArtifactsDir, sourceDir)
|
||||
}
|
||||
if task.ReportJSONPath != filepath.Join(sourceDir, "report.json") {
|
||||
t.Fatalf("report path = %q, want source directory", task.ReportJSONPath)
|
||||
}
|
||||
}
|
||||
|
||||
func TestHandleAPITasksStreamReplaysPersistedLogWithoutLiveJob(t *testing.T) {
|
||||
dir := t.TempDir()
|
||||
logPath := filepath.Join(dir, "task.log")
|
||||
|
||||
Reference in New Issue
Block a user