MCPcopy Create free account
hub / github.com/github/gh-aw / TestViewWorkflowRun_LocalCache_NoError

Function TestViewWorkflowRun_LocalCache_NoError

pkg/cli/view_command_test.go:130–183  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

128}
129
130func TestViewWorkflowRun_LocalCache_NoError(t *testing.T) {
131 logsDir := buildViewRunDir(t)
132
133 opts := ViewOptions{
134 OutputDir: logsDir,
135 Verbose: false,
136 }
137 // Capture stdout so we can assert on the rendered timeline output.
138 origStdout := os.Stdout
139 r, w, err := os.Pipe()
140 if err != nil {
141 t.Fatalf("os.Pipe: %v", err)
142 }
143 os.Stdout = w
144
145 runErr := ViewWorkflowRun(context.Background(), 9999, opts)
146
147 // Restore stdout and read captured output.
148 w.Close()
149 os.Stdout = origStdout
150 outBytes, readErr := io.ReadAll(r)
151 if readErr != nil {
152 t.Fatalf("reading captured output: %v", readErr)
153 }
154 output := string(outBytes)
155
156 if runErr != nil {
157 t.Errorf("ViewWorkflowRun returned unexpected error: %v", runErr)
158 }
159
160 // Verify that renderUnifiedTimelineStream produced streaming output:
161 // agent turns as "> Turn N [time]" headers, tool events with icons, no stats or table.
162 for _, want := range []string{"> Turn 1", "github/search"} {
163 if !strings.Contains(output, want) {
164 t.Errorf("output missing %q; got:\n%s", want, output)
165 }
166 }
167 // Verify user/assistant/reasoning message content snippets are rendered.
168 for _, want := range []string{
169 "What files are in the repo?",
170 "I found the following files in the repo.",
171 "The user wants a list of files.",
172 } {
173 if !strings.Contains(output, want) {
174 t.Errorf("output missing message snippet %q; got:\n%s", want, output)
175 }
176 }
177 // Confirm there are no stats or table headers in the stream output.
178 for _, notWant := range []string{"Total Events", "Event Timeline", "Gateway", "Firewall"} {
179 if strings.Contains(output, notWant) {
180 t.Errorf("stream output should not contain %q; got:\n%s", notWant, output)
181 }
182 }
183}
184
185func TestViewWorkflowRun_WithOwnerRepo_ShowsRunURL(t *testing.T) {
186 logsDir := buildViewRunDir(t)

Callers

nothing calls this directly

Calls 5

buildViewRunDirFunction · 0.85
ViewWorkflowRunFunction · 0.85
BackgroundMethod · 0.80
CloseMethod · 0.65
ErrorfMethod · 0.45

Tested by

no test coverage detected