diff --git a/pkg/cli/view_command_test.go b/pkg/cli/view_command_test.go index 50c8d68382d..9676a8fb0ac 100644 --- a/pkg/cli/view_command_test.go +++ b/pkg/cli/view_command_test.go @@ -121,9 +121,13 @@ func buildViewRunDir(t *testing.T) string { t.Fatalf("WriteFile events.jsonl: %v", err) } - // Mark the directory as already downloaded so downloadRunArtifacts skips - // network calls (it returns early when the dir is non-empty and has no cached - // summary — it just skips the download and lets the caller process what's there). + // Write the complete-download marker so downloadRunArtifacts skips network + // calls (it requires the ".downloaded-artifacts/all" marker to be present + // before it will use the cached directory contents). + if err := markArtifactDownloaded(runDir, string(ArtifactSetAll)); err != nil { + t.Fatalf("markArtifactDownloaded: %v", err) + } + return dir } @@ -272,17 +276,17 @@ func TestViewWorkflowRun_WithSafeOutputs_ShowsSection(t *testing.T) { } func TestViewWorkflowRun_EmptyDir_WarnsAndReturnsNil(t *testing.T) { - // A run dir that is non-empty (so downloadRunArtifacts skips the network call) - // but contains no JSONL files → no events → warning, no error. + // A run dir that has the complete-download marker but contains no JSONL files + // → no events → warning, no error. logsDir := t.TempDir() runDir := filepath.Join(logsDir, "run-1111") if err := os.MkdirAll(runDir, 0755); err != nil { t.Fatalf("MkdirAll: %v", err) } - // Place a dummy file so the directory is not empty; downloadRunArtifacts will - // skip the download when the dir is non-empty (no valid cached summary). - if err := os.WriteFile(filepath.Join(runDir, "placeholder.txt"), []byte("x"), 0600); err != nil { - t.Fatalf("WriteFile placeholder: %v", err) + // Write the complete-download marker so downloadRunArtifacts skips network + // calls; the run dir has no JSONL files so the timeline will be empty. + if err := markArtifactDownloaded(runDir, string(ArtifactSetAll)); err != nil { + t.Fatalf("markArtifactDownloaded: %v", err) } opts := ViewOptions{