mirror of
https://github.com/cargo-bins/cargo-binstall.git
synced 2025-04-20 20:48:43 +00:00

* Impl new mod `hosting` for detecting git hosting services * Refactor: Make `guess_git_hosting_services` associated fn of `GitHostingService` * Set default value of `PkgMeta::pkg_url` to `None` * Impl new method `get_redirected_final_url` * Use `get_redirected_final_url` in `GhCrateMeta::find` to make `guess_git_hosting_services` more accurate. * Use redirected `repo` in `GhCrateMeta::launch_baseline_find_tasks` * Refactor `<GhCrateMeta as Fetcher>::find` * Mod `get_default_pkg_url_template` to ret `&[&str]` * Add more default `pkg-url` templates * Rm `pkg-url` in `bin/Cargo.toml` Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
31 lines
988 B
Rust
31 lines
988 B
Rust
use binstall::ops::resolve::load_manifest_path;
|
|
use cargo_toml::Product;
|
|
|
|
#[test]
|
|
fn parse_meta() {
|
|
let _ = env_logger::builder().is_test(true).try_init();
|
|
|
|
let mut manifest_dir = std::env::var("CARGO_MANIFEST_DIR").unwrap();
|
|
manifest_dir.push_str("/tests/parse-meta.Cargo.toml");
|
|
|
|
let manifest = load_manifest_path(&manifest_dir).expect("Error parsing metadata");
|
|
let package = manifest.package.unwrap();
|
|
let meta = package.metadata.and_then(|m| m.binstall).unwrap();
|
|
|
|
assert_eq!(&package.name, "cargo-binstall-test");
|
|
|
|
assert_eq!(
|
|
meta.pkg_url.as_deref().unwrap(),
|
|
"{ repo }/releases/download/v{ version }/{ name }-{ target }.{ archive-format }"
|
|
);
|
|
|
|
assert_eq!(
|
|
manifest.bin.as_slice(),
|
|
&[Product {
|
|
name: Some("cargo-binstall".to_string()),
|
|
path: Some("src/main.rs".to_string()),
|
|
edition: Some(cargo_toml::Edition::E2021),
|
|
..Default::default()
|
|
},],
|
|
);
|
|
}
|