MCPcopy Create free account
hub / github.com/dtormoen/tsk-tsk / test_task_builder_with_branch

Function test_task_builder_with_branch

src/task_builder.rs:1617–1679  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

1615
1616 #[tokio::test]
1617 async fn test_task_builder_with_branch() {
1618 use crate::test_utils::TestGitRepository;
1619
1620 let test_repo = TestGitRepository::new().unwrap();
1621 test_repo.init_with_main_branch().unwrap();
1622 test_repo.create_file("main-file.txt", "content").unwrap();
1623 test_repo.stage_all().unwrap();
1624 let main_commit = test_repo.commit("Add main file").unwrap();
1625
1626 // Create a feature branch with a different commit
1627 test_repo
1628 .run_git_command(&["checkout", "-b", "feature-branch"])
1629 .unwrap();
1630 test_repo
1631 .create_file("feature-file.txt", "feature")
1632 .unwrap();
1633 test_repo.stage_all().unwrap();
1634 test_repo.commit("Add feature file").unwrap();
1635
1636 // Go back to main
1637 test_repo.run_git_command(&["checkout", "main"]).unwrap();
1638
1639 // Create uncommitted changes on main that should NOT appear in --branch copy
1640 test_repo
1641 .create_file("dirty-file.txt", "uncommitted")
1642 .unwrap();
1643
1644 let ctx = AppContext::builder().build();
1645
1646 // Build task from feature-branch while on main
1647 let task = TaskBuilder::new()
1648 .repo_root(test_repo.path().to_path_buf())
1649 .name("branch-test".to_string())
1650 .prompt(Some("Test".to_string()))
1651 .branch(Some("feature-branch".to_string()))
1652 .build(&ctx)
1653 .await
1654 .unwrap();
1655
1656 assert_eq!(task.source_branch, Some("feature-branch".to_string()));
1657 assert_ne!(
1658 task.source_commit, main_commit,
1659 "Should use feature-branch commit, not main"
1660 );
1661
1662 // Verify the copied repo has the feature file
1663 let task_dir = ctx.tsk_env().task_dir(&task.id);
1664 let copied_repo = task_dir.join("repo");
1665 assert!(
1666 copied_repo.join("feature-file.txt").exists(),
1667 "Should have feature-branch files"
1668 );
1669 assert!(
1670 copied_repo.join("main-file.txt").exists(),
1671 "Should have main-file.txt too"
1672 );
1673
1674 // Verify uncommitted working tree changes are NOT included

Callers

nothing calls this directly

Calls 13

init_with_main_branchMethod · 0.80
create_fileMethod · 0.80
stage_allMethod · 0.80
commitMethod · 0.80
run_git_commandMethod · 0.80
branchMethod · 0.80
promptMethod · 0.80
repo_rootMethod · 0.80
pathMethod · 0.80
task_dirMethod · 0.80
tsk_envMethod · 0.80
buildMethod · 0.45

Tested by

no test coverage detected