@@ -336,15 +336,30 @@ sleep 10
|
336 | 336 | } |
337 | 337 | |
338 | 338 | func TestPreviewCommandOutputFlattensAndTruncates(t *testing.T) { |
339 | | -input := "line one\n\nline two\tline three " + strings.Repeat("x", 600) |
| 339 | +input := "line one\n\nline two\tline three " + strings.Repeat("x", 1200) + " final api error 429" |
340 | 340 | preview := previewCommandOutput(input, "") |
341 | 341 | if strings.Contains(preview, "\n") { |
342 | 342 | t.Fatalf("expected flattened whitespace, got %q", preview) |
343 | 343 | } |
344 | 344 | if !strings.HasPrefix(preview, "line one line two line three ") { |
345 | 345 | t.Fatalf("unexpected preview prefix: %q", preview) |
346 | 346 | } |
347 | | -if !strings.HasSuffix(preview, "...") { |
348 | | -t.Fatalf("expected truncation suffix, got %q", preview) |
| 347 | +if !strings.Contains(preview, "... [truncated] ...") { |
| 348 | +t.Fatalf("expected truncation marker, got %q", preview) |
| 349 | + } |
| 350 | +if !strings.HasSuffix(preview, "final api error 429") { |
| 351 | +t.Fatalf("expected retained error tail, got %q", preview) |
| 352 | + } |
| 353 | +} |
| 354 | + |
| 355 | +func TestPreviewCommandOutputRetainsStderrTail(t *testing.T) { |
| 356 | +stdout := "startup banner " + strings.Repeat("x", 1200) |
| 357 | +stderr := "provider api error 429" |
| 358 | +preview := previewCommandOutput(stdout, stderr) |
| 359 | +if !strings.HasPrefix(preview, "startup banner ") { |
| 360 | +t.Fatalf("unexpected preview prefix: %q", preview) |
| 361 | + } |
| 362 | +if !strings.HasSuffix(preview, stderr) { |
| 363 | +t.Fatalf("expected retained stderr tail, got %q", preview) |
349 | 364 | } |
350 | 365 | } |