cargo-binstall/crates/binstalk/tests/parse-meta.rs
Jiahao XU aeacebcf83
feat: Support passing workspace to --manifest-path (#1246)
Previously it will load the root `Cargo.toml` and treat it as the
manifest for the crate, now it will check its `package.name` and would
search for the workspace if the `package.name` does not match the crate
name.

Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
2023-08-03 21:12:06 +00:00

31 lines
989 B
Rust

use binstalk::ops::resolve::load_manifest_path;
use cargo_toml::Product;
use std::path::PathBuf;
#[test]
fn parse_meta() {
let mut manifest_dir = PathBuf::from(std::env::var_os("CARGO_MANIFEST_DIR").unwrap());
manifest_dir.push("tests/parse-meta.Cargo.toml");
let manifest =
load_manifest_path(&manifest_dir, "cargo-binstall-test").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: cargo_toml::Edition::E2021,
..Default::default()
},],
);
}