e2e: Fix false-positive in canonical ref update test

Previously `test_fetch_emits_canonical_ref_update` was passing by
catching a leftover `CanonicalRefUpdated` event from the initial
repository fetch. Furthermore, the new commit was written to the
un-namespaced root. It can be proven to be the case by commenting out
the `alice.commit_to(...)` line and watching the test still pass.

Fix the test by committing to the namespaced default branch which will
trigger the `CanonicalRefUpdated` that is expected by Bob. Drains events
so we don't catch the wrong event, and explicitly announces.
This commit is contained in:
Adrian Duke 2026-05-01 11:58:20 +01:00 committed by Fintan Halpenny
parent ed340f5724
commit 80d30d3b59
1 changed files with 7 additions and 0 deletions

View File

@ -1691,13 +1691,20 @@ fn test_fetch_emits_canonical_ref_update() {
.unwrap();
assert!(result.is_success());
// Drain all the events including initial `CanonicalRefUpdated`
// from fetch
while bob_events.try_recv().is_ok() {}
let default_branch: git::fmt::Qualified = {
let repo = alice.storage.repository(rid).unwrap();
let proj = repo.project().unwrap();
git::fmt::lit::refs_heads(proj.default_branch()).into()
};
alice.commit_to(rid, &default_branch);
alice.handle.announce_refs_for(rid, [alice.id]).unwrap();
bob_events
.wait(
|e| {