(t *testing.T)
| 478 | } |
| 479 | |
| 480 | func TestRunSnapshot_FileOutput(t *testing.T) { |
| 481 | tmpDir := createSnapshotTestFiles(t) |
| 482 | resetSnapshotFlags() |
| 483 | |
| 484 | outFile := filepath.Join(t.TempDir(), "snapshot.json") |
| 485 | snapshotOut = outFile |
| 486 | |
| 487 | _, err := captureSnapshotOutput(t, []string{tmpDir}) |
| 488 | if err != nil { |
| 489 | t.Fatalf("runSnapshot failed: %v", err) |
| 490 | } |
| 491 | |
| 492 | data, err := os.ReadFile(outFile) |
| 493 | if err != nil { |
| 494 | t.Fatalf("failed to read output file: %v", err) |
| 495 | } |
| 496 | |
| 497 | var result SnapshotOutput |
| 498 | if err := json.Unmarshal(data, &result); err != nil { |
| 499 | t.Fatalf("output file is not valid JSON: %v", err) |
| 500 | } |
| 501 | if len(result.Tasks) != 4 { |
| 502 | t.Errorf("expected 4 tasks in file, got %d", len(result.Tasks)) |
| 503 | } |
| 504 | } |
| 505 | |
| 506 | func TestRunSnapshot_InvalidFormat(t *testing.T) { |
| 507 | tmpDir := createSnapshotTestFiles(t) |
nothing calls this directly
no test coverage detected