Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 13 additions & 9 deletions pkg/cli/view_command_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down Expand Up @@ -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{
Expand Down