()
| 480 | |
| 481 | #[test] |
| 482 | fn test_status_command_with_pr_flag() { |
| 483 | let test_name = "test_status_with_pr"; |
| 484 | let repo = setup_git_repo(test_name); |
| 485 | let path_to_repo = generate_path_to_repo(test_name); |
| 486 | |
| 487 | // Set up mock gh |
| 488 | let mock_dir = setup_mock_gh(test_name); |
| 489 | |
| 490 | // Create initial commit on main branch |
| 491 | create_new_file(&path_to_repo, "README.md", "Initial commit"); |
| 492 | first_commit_all(&repo, "Initial commit"); |
| 493 | |
| 494 | // Rename master to main |
| 495 | { |
| 496 | let mut master_branch = repo.find_branch("master", git2::BranchType::Local).unwrap(); |
| 497 | master_branch.rename("main", false).unwrap(); |
| 498 | } |
| 499 | |
| 500 | // Create a branch |
| 501 | create_branch(&repo, "feature-with-pr"); |
| 502 | checkout_branch(&repo, "feature-with-pr"); |
| 503 | create_new_file(&path_to_repo, "feature.txt", "Feature"); |
| 504 | commit_all(&repo, "Add feature"); |
| 505 | |
| 506 | // Initialize chain |
| 507 | run_test_bin_expect_ok(&path_to_repo, ["init", "test-chain", "main"]); |
| 508 | |
| 509 | // Update PATH |
| 510 | let original_path = env::var("PATH").unwrap_or_default(); |
| 511 | let absolute_mock_dir = mock_dir.canonicalize().unwrap(); |
| 512 | let new_path = format!("{}:{}", absolute_mock_dir.display(), original_path); |
| 513 | |
| 514 | // Run status command with --pr flag and modified PATH |
| 515 | let output = run_test_bin_with_env(path_to_repo, ["status", "--pr"], vec![("PATH", new_path)]); |
| 516 | |
| 517 | let stdout = String::from_utf8_lossy(&output.stdout); |
| 518 | let stderr = String::from_utf8_lossy(&output.stderr); |
| 519 | |
| 520 | // Debug output |
| 521 | println!("=== TEST DIAGNOSTICS ==="); |
| 522 | println!("STDOUT: {}", stdout); |
| 523 | println!("STDERR: {}", stderr); |
| 524 | println!("EXIT STATUS: {}", output.status); |
| 525 | println!("======"); |
| 526 | |
| 527 | // Assertions |
| 528 | assert!(output.status.success(), "Command should succeed"); |
| 529 | assert!(stdout.contains("test-chain"), "Should show chain name"); |
| 530 | assert!( |
| 531 | stdout.contains("feature-with-pr"), |
| 532 | "Should show branch name" |
| 533 | ); |
| 534 | assert!( |
| 535 | stdout.contains("https://github.com/test/repo/pull/123"), |
| 536 | "Should show PR URL for feature-with-pr, got: {}", |
| 537 | stdout |
| 538 | ); |
| 539 |
nothing calls this directly
no test coverage detected