Skip to content

Commit ae1bc41

Browse files
committed
Add test to validate alternates in the context of fetching
1 parent af0ef2f commit ae1bc41

File tree

1 file changed

+47
-0
lines changed

1 file changed

+47
-0
lines changed

gix/tests/remote/fetch.rs

+47
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,53 @@ mod blocking_and_async_io {
109109
Ok(())
110110
}
111111

112+
#[test]
113+
#[cfg(feature = "blocking-network-client")]
114+
fn fetch_with_alternates_adds_tips_from_alternates() -> crate::Result<()> {
115+
let tmp = gix_testtools::tempfile::TempDir::new()?;
116+
let remote_repo = remote::repo("base");
117+
let (_repo, out) = gix::clone::PrepareFetch::new(
118+
remote::repo("multi_round/server").path(),
119+
tmp.path(),
120+
gix::create::Kind::Bare,
121+
Default::default(),
122+
gix::open::Options::isolated(),
123+
)?
124+
.configure_remote({
125+
move |r| {
126+
std::fs::write(
127+
r.repo().objects.store_ref().path().join("info").join("alternates"),
128+
format!(
129+
"{}\n",
130+
gix::path::realpath(remote_repo.objects.store_ref().path())?.display()
131+
)
132+
.as_bytes(),
133+
)?;
134+
Ok(r)
135+
}
136+
})
137+
.fetch_only(gix::progress::Discard, &AtomicBool::default())?;
138+
139+
match out.status {
140+
Status::Change {
141+
negotiation_rounds,
142+
write_pack_bundle,
143+
..
144+
} => {
145+
assert_eq!(
146+
negotiation_rounds, 1,
147+
"we don't really have a way to see that tips from alternates were added, I think"
148+
);
149+
assert_eq!(
150+
write_pack_bundle.index.num_objects, 66,
151+
"this test just exercises code for adding alternate-repo tips to the negotiator"
152+
);
153+
}
154+
_ => unreachable!("we get a pack as alternates are unrelated"),
155+
}
156+
Ok(())
157+
}
158+
112159
#[maybe_async::test(
113160
feature = "blocking-network-client",
114161
async(feature = "async-network-client-async-std", async_std::test)

0 commit comments

Comments
 (0)