hive-forge: test the two invariants dependency.rs documents but never checked
dep_meta's comment records a measured 404: leaving owner/repo as None made every same-repo dependency fail, because forgejo resolves the dependency's repo from the request BODY rather than the URL. Nothing stopped a later tidy-up from simplifying them back to None. index() promises "error instead of wrapping". A wrap would not fail loudly -- it would hand the forge a negative index it looks up as some other issue.
This commit is contained in:
parent
e0c2f1aeaa
commit
74b48c5afa
2 changed files with 41 additions and 1 deletions
|
|
@ -186,3 +186,28 @@ fn dep_meta(owner: &str, repo: &str, dep: u64) -> Result<IssueMeta> {
|
|||
repo: Some(repo.to_owned()),
|
||||
})
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
/// The comment above `dep_meta` records a measured failure: leaving
|
||||
/// `owner`/`repo` as `None` made every same-repo dependency 404,
|
||||
/// because forgejo resolves the dependency's repo from the *body*
|
||||
/// rather than falling back to the request URL. Nothing but a test
|
||||
/// stops a future tidy-up from "simplifying" them back to `None`.
|
||||
#[test]
|
||||
fn dep_meta_populates_owner_and_repo_rather_than_leaving_them_none() {
|
||||
let m = dep_meta("hyperhive", "hyperhive", 3950).expect("in range");
|
||||
assert_eq!(m.owner.as_deref(), Some("hyperhive"));
|
||||
assert_eq!(m.repo.as_deref(), Some("hyperhive"));
|
||||
assert_eq!(m.index, Some(3950));
|
||||
}
|
||||
|
||||
/// Out-of-range must be an error, not a wrapped negative index that
|
||||
/// the forge would then look up as some other issue.
|
||||
#[test]
|
||||
fn dep_meta_refuses_a_number_no_forge_could_have() {
|
||||
assert!(dep_meta("o", "r", u64::MAX).is_err());
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue