Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: init rocket dependency version #314

Merged
merged 5 commits into from
Aug 25, 2022
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 22 additions & 1 deletion cargo-shuttle/src/init.rs
Original file line number Diff line number Diff line change
Expand Up @@ -425,7 +425,10 @@ type GetDependencyVersionFn = fn(&str, &Path, &Url) -> String;
/// Gets the latest version for a dependency of `crate_name`.
/// This is a wrapper function for `cargo_edit::get_latest_dependency` function.
fn get_latest_dependency_version(crate_name: &str, manifest_path: &Path, url: &Url) -> String {
let latest_version = get_latest_dependency(crate_name, false, manifest_path, Some(url))
// some crates need to be on the prerelease version
let flag_allow_prerelease = matches!(crate_name, "rocket");
coszio marked this conversation as resolved.
Show resolved Hide resolved

let latest_version = get_latest_dependency(crate_name, flag_allow_prerelease, manifest_path, Some(url))
.unwrap_or_else(|_| panic!("Could not query the latest version of {}", crate_name));
let latest_version = latest_version
.version()
Expand Down Expand Up @@ -725,4 +728,22 @@ mod shuttle_init_tests {

assert_eq!(cargo_toml.to_string(), expected);
}

#[test]
fn test_get_latest_dependency_version_rocket() {

let manifest_path = PathBuf::new();

let url = Url::parse("https://github.com/rust-lang/crates.io-index").unwrap();

let version = get_latest_dependency_version("rocket", &manifest_path, &url);

let expected = get_latest_dependency("rocket", true, &manifest_path, Some(&url))
.expect("Could not query the latest version of rocket")
.version()
.expect("no shuttle-service version found")
chesedo marked this conversation as resolved.
Show resolved Hide resolved
.to_string();

assert_eq!(version, expected);
}
}