cargo-binstall/crates/binstalk/tests/parse-meta.rs
Jiahao XU 8ff13c1b36
Refactor: Extract cargo_toml_workspace as a new crate (#1287)
To reduce codegen time of `binstalk` and also enable others to reuse
this crate.

Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
2023-08-12 12:05:10 +00:00

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()
},],
);
}