Add a real download test — every other one only tests the bookkeeping
Every existing test in model.rs exercises the URL construction, the .part rename, the progress callback — all against a filesystem, never against Hugging Face. The FFI smoke test in speech.rs proves the recogniser loads a model, but that model got there by curl, not by this app's own download(). Nothing in this codebase had ever actually called ureq against the real service the download URLs point at. That gap mattered: ureq needs its `tls` feature for `https://` to work at all, and while it turns out to be on by default, verifying that assumption once, for real, against 44 MB from the actual host, is worth more than believing a Cargo.toml default is what the docs say it is. Ignored by default like the other network-dependent test — this one costs real bytes and real time — but it now exists, and it passed.
This commit is contained in:
parent
e8623faf44
commit
0137a7a725
1 changed files with 53 additions and 0 deletions
|
|
@ -330,4 +330,57 @@ mod tests {
|
||||||
directories.dedup();
|
directories.dedup();
|
||||||
assert_eq!(directories.len(), count, "two models share a directory");
|
assert_eq!(directories.len(), count, "two models share a directory");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Downloads the default model over a real network connection.
|
||||||
|
///
|
||||||
|
/// Every other test in this module exercises the bookkeeping around a
|
||||||
|
/// download without ever making one — the URL, the `.part` rename, the
|
||||||
|
/// progress callback are all tested against a filesystem, never against
|
||||||
|
/// Hugging Face. This is the one place that calls `ureq` for real, which
|
||||||
|
/// is the only way to know the TLS setup and the URL format actually work
|
||||||
|
/// against the service they are pointed at, rather than just against each
|
||||||
|
/// other.
|
||||||
|
///
|
||||||
|
/// Ignored by default — real network access, and ~44 MB — but this is
|
||||||
|
/// exactly the code path "Download" runs in the app, unlike the FFI smoke
|
||||||
|
/// test in speech.rs, which is handed a model fetched some other way.
|
||||||
|
#[test]
|
||||||
|
#[ignore = "downloads ~44 MB over a real network connection"]
|
||||||
|
fn the_default_model_downloads_and_installs_for_real() {
|
||||||
|
let root = temp_root_for_download();
|
||||||
|
let model = default_model();
|
||||||
|
|
||||||
|
let mut progress_seen = false;
|
||||||
|
let mut final_progress = DownloadProgress {
|
||||||
|
received: 0,
|
||||||
|
total: 0,
|
||||||
|
};
|
||||||
|
download(&root, model, |progress| {
|
||||||
|
progress_seen = true;
|
||||||
|
final_progress = progress;
|
||||||
|
})
|
||||||
|
.expect("a real download of the default model should succeed");
|
||||||
|
|
||||||
|
assert!(progress_seen, "the progress callback should fire at least once");
|
||||||
|
assert!(
|
||||||
|
final_progress.received > 0,
|
||||||
|
"should report having received bytes"
|
||||||
|
);
|
||||||
|
|
||||||
|
let paths = paths(&root, model);
|
||||||
|
assert!(paths.all_present(), "all four files should be on disk");
|
||||||
|
assert!(
|
||||||
|
fs::metadata(&paths.encoder).unwrap().len() > 1_000_000,
|
||||||
|
"the encoder should not be a truncated stub"
|
||||||
|
);
|
||||||
|
assert!(status(&root, model).installed);
|
||||||
|
|
||||||
|
let _ = fs::remove_dir_all(&root);
|
||||||
|
}
|
||||||
|
|
||||||
|
fn temp_root_for_download() -> PathBuf {
|
||||||
|
let root = std::env::temp_dir().join("textream-model-download-test");
|
||||||
|
let _ = fs::remove_dir_all(&root);
|
||||||
|
root
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue