MCPcopy Create free account
hub / github.com/dashed/git-chain / test_pr_command_skips_existing_prs

Function test_pr_command_skips_existing_prs

tests/pr.rs:226–307  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

224
225#[test]
226fn test_pr_command_skips_existing_prs() {
227 let test_name = "test_pr_skips_existing";
228 let repo = setup_git_repo(test_name);
229 let path_to_repo = generate_path_to_repo(test_name);
230
231 // Set up mock gh
232 let mock_dir = setup_mock_gh(test_name);
233
234 // Create initial commit on main branch
235 create_new_file(&path_to_repo, "README.md", "Initial commit");
236 first_commit_all(&repo, "Initial commit");
237
238 // Rename master to main
239 {
240 let mut master_branch = repo.find_branch("master", git2::BranchType::Local).unwrap();
241 master_branch.rename("main", false).unwrap();
242 }
243
244 // Create branches that will have existing PRs
245 create_branch(&repo, "feature-with-pr");
246 checkout_branch(&repo, "feature-with-pr");
247 create_new_file(&path_to_repo, "feature.txt", "Feature");
248 commit_all(&repo, "Add feature");
249
250 // Initialize chain
251 run_test_bin_expect_ok(&path_to_repo, ["init", "pr-chain", "main"]);
252
253 create_branch(&repo, "feature-merged");
254 checkout_branch(&repo, "feature-merged");
255 create_new_file(&path_to_repo, "merged.txt", "Merged feature");
256 commit_all(&repo, "Add merged feature");
257
258 // Initialize chain for feature-merged
259 run_test_bin_expect_ok(&path_to_repo, ["init", "pr-chain", "feature-with-pr"]);
260
261 // Update PATH
262 let original_path = env::var("PATH").unwrap_or_default();
263 let absolute_mock_dir = mock_dir.canonicalize().unwrap();
264 let new_path = format!("{}:{}", absolute_mock_dir.display(), original_path);
265 env::set_var("PATH", new_path);
266
267 // Run pr command
268 let output = run_test_bin(path_to_repo, ["pr"]);
269
270 // Restore original PATH
271 env::set_var("PATH", original_path);
272
273 let stdout = String::from_utf8_lossy(&output.stdout);
274 let stderr = String::from_utf8_lossy(&output.stderr);
275
276 // Debug output
277 println!("=== TEST DIAGNOSTICS ===");
278 println!("STDOUT: {}", stdout);
279 println!("STDERR: {}", stderr);
280 println!("EXIT STATUS: {}", output.status);
281 println!("======");
282
283 // Assertions

Callers

nothing calls this directly

Calls 12

setup_git_repoFunction · 0.85
generate_path_to_repoFunction · 0.85
setup_mock_ghFunction · 0.85
create_new_fileFunction · 0.85
first_commit_allFunction · 0.85
create_branchFunction · 0.85
checkout_branchFunction · 0.85
commit_allFunction · 0.85
run_test_bin_expect_okFunction · 0.85
run_test_binFunction · 0.85
teardown_git_repoFunction · 0.85
renameMethod · 0.80

Tested by

no test coverage detected