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

To reduce codegen time of `binstalk` and also enable others to reuse this crate. Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
31 lines
1,010 B
Rust
31 lines
1,010 B
Rust
use binstalk::ops::resolve::load_manifest_path;
|
|
use cargo_toml_workspace::cargo_toml::{Edition, 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: Edition::E2021,
|
|
..Default::default()
|
|
},],
|
|
);
|
|
}
|