Skip to content

Commit

Permalink
Add test for yanked release logic
Browse files Browse the repository at this point in the history
  • Loading branch information
Tyrubias authored and syphar committed Feb 14, 2024
1 parent fc6ce05 commit a0c5cca
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/web/releases.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1248,6 +1248,12 @@ mod tests {
.version("0.0.1")
.create()?;

env.fake_release()
.name("yet_another_crate")
.version("0.1.0")
.yanked(true)
.create()?;

let _m = crates_io
.mock("GET", "/api/v1/crates")
.match_query(Matcher::AllOf(vec![
Expand All @@ -1262,6 +1268,7 @@ mod tests {
{ "name": "some_random_crate" },
{ "name": "some_other_crate" },
{ "name": "and_another_one" },
{ "name": "yet_another_crate" }
],
"meta": {
"next_page": null,
Expand All @@ -1275,13 +1282,14 @@ mod tests {
let links = get_release_links("/releases/search?query=some_random_crate", web)?;

// `some_other_crate` won't be shown since we don't have it yet
assert_eq!(links.len(), 2);
assert_eq!(links.len(), 3);
// * `max_version` from the crates.io search result will be ignored since we
// might not have it yet, or the doc-build might be in progress.
// * ranking/order from crates.io result is preserved
// * version used is the highest semver following our own "latest version" logic
assert_eq!(links[0], "/some_random_crate/latest/some_random_crate/");
assert_eq!(links[1], "/and_another_one/latest/and_another_one/");
assert_eq!(links[2], "/yet_another_crate/0.1.0/yet_another_crate/");
Ok(())
})
}
Expand Down

0 comments on commit a0c5cca

Please sign in to comment.