Files
branchgraph/tests/fetch.rs
Jean-Gabriel Gill-Couture e03a92c570 Remove dead code, merge duplicated logic, match docs to the code
- Drop fields and functions nothing reads: job and proc tips, fetch time,
  PR url/author (and their GraphQL fields), spine summaries, diff::commit,
  unread data attributes, unused CSS and tokens.
- One home each for state wording (naming main as the repo does), lane
  lookup, unseen, outdated, main's tip, the stop wait and the token header.
- Narrow visibility; rename render::View to Filter; queue ranking moves
  to the CLI, its only user.
- Token test covers every route; shared checkout snapshot in the fixture.
- Client: errors outside Run/Send are toasts, history only after a good
  load, a drag stays in one file, the agent marker is a ring.
- design.md, the skill and AGENTS.md describe what is built.
2026-10-09 12:24:24 -04:00

43 lines
1.3 KiB
Rust

mod fixture;
use branchgraph::{fetch, git};
use fixture::{Fixture, commit, git as run};
#[test]
fn fetch_brings_a_teammates_branch_and_touches_nothing_else() {
let f = Fixture::new();
let c = f.clone.as_path();
let mate = c.parent().unwrap().join("mate");
run(
c.parent().unwrap(),
&["clone", "-q", "origin.git", mate.to_str().unwrap()],
);
run(&mate, &["checkout", "-q", "-b", "feat/mate"]);
commit(&mate, "mate.txt", "hi\n", "mate 1");
run(&mate, &["push", "-q", "origin", "feat/mate"]);
let before = fixture::checkout_state(c);
let local = run(c, &["for-each-ref", "refs/heads"]);
let repo = git::open(c).unwrap();
assert!(fetch::fetch(&repo).unwrap());
assert_eq!(
run(c, &["rev-parse", "origin/feat/mate"]),
run(&mate, &["rev-parse", "HEAD"])
);
assert_eq!(fixture::checkout_state(c), before);
assert_eq!(run(c, &["for-each-ref", "refs/heads"]), local);
}
#[test]
fn fetch_waits_while_git_holds_a_lock() {
let f = Fixture::new();
let lock = f.clone.join(".git/packed-refs.lock");
std::fs::write(&lock, "").unwrap();
let repo = git::open(&f.clone).unwrap();
assert!(!fetch::fetch(&repo).unwrap());
std::fs::remove_file(&lock).unwrap();
assert!(fetch::fetch(&repo).unwrap());
}