huginn-sources: fix the slow-reserve stub's CRLF and the revert test's premise

The failed-upsert revert test now expects chunks of two commits, since
nothing is deleted before the new chunks land.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Meta Vens 2026-11-02 21:58:34 +01:00
commit d9a4c27e70
2 changed files with 8 additions and 12 deletions

View file

@ -170,9 +170,7 @@ mod tests {
Ok(read) => buffer.extend_from_slice(&chunk[..read]),
}
let text = String::from_utf8_lossy(&buffer).into_owned();
if let Some(end) = text.find("
") {
if let Some(end) = text.find("\r\n\r\n") {
let length = text.lines().find_map(|line| line.to_ascii_lowercase().strip_prefix("content-length:").map(|v| v.trim().parse().unwrap())).unwrap_or(0);
break (end + 4, length);
}
@ -193,10 +191,7 @@ mod tests {
std::thread::sleep(delay);
r#"{"embeddings":[[1.0]]}"#
};
let _ = write!(stream, "HTTP/1.1 200 OK
content-length: {}
{body}", body.len());
let _ = write!(stream, "HTTP/1.1 200 OK\r\ncontent-length: {}\r\n\r\n{body}", body.len());
});
}
});

View file

@ -217,10 +217,10 @@ fn cursor_never_leads() {
assert_eq!(rig.index.ids(), clean.index.ids());
}
/// A run that fails between a repo's deletes and its upserts leaves chunks of
/// no single commit. A head that then reverts the files to the old content
/// makes an empty diff from the old commit, which would keep the deleted
/// chunks deleted; the repo is ingested whole instead.
/// A run that fails part way through a repo's upserts leaves chunks of two
/// commits. A head that then reverts the files to the old content makes an
/// empty diff from the old commit, which would keep the half-written new chunks;
/// the repo is ingested whole instead and only the head's chunks remain.
#[test]
fn a_failed_run_then_a_revert_converges() {
let remote = Remote::new();
@ -242,7 +242,8 @@ fn a_failed_run_then_a_revert_converges() {
}
let (refreshed, _) = rig.run(&mut forge);
assert_eq!(refreshed.unwrap().failed, ["Demo"]);
assert!(rig.index.held().len() < 40, "the failed run left a partial repo");
let commits: BTreeSet<String> = rig.index.held().into_iter().map(|(.., commit)| commit).collect();
assert_eq!(commits.len(), 2, "the failed run left chunks of two commits");
rig.index.state.lock().unwrap().fail_upserts_after = None;
let c = remote.commit(&original, &[]);