cargo-binstall/crates/binstalk/tests/parse-meta.rs
dependabot[bot] e9f25187d7
build(deps): bump the deps group with 3 updates (#1993)
* build(deps): bump the deps group with 3 updates

Bumps the deps group with 3 updates: [target-lexicon](https://github.com/bytecodealliance/target-lexicon), [cargo_toml](https://gitlab.com/lib.rs/cargo_toml) and [fs4](https://github.com/al8n/fs4-rs).


Updates `target-lexicon` from 0.12.16 to 0.13.0
- [Commits](https://github.com/bytecodealliance/target-lexicon/compare/v0.12.16...v0.13.0)

Updates `cargo_toml` from 0.20.5 to 0.21.0
- [Commits](https://gitlab.com/lib.rs/cargo_toml/commits/main)

Updates `fs4` from 0.11.1 to 0.12.0
- [Release notes](https://github.com/al8n/fs4-rs/releases)
- [Commits](https://github.com/al8n/fs4-rs/commits)

---
updated-dependencies:
- dependency-name: target-lexicon
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: deps
- dependency-name: cargo_toml
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: deps
- dependency-name: fs4
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: deps
...

Signed-off-by: dependabot[bot] <support@github.com>

* Fix use of cargo-toml in parse-meta.rs

Signed-off-by: Jiahao XU <30436523+NobodyXu@users.noreply.github.com>

---------

Signed-off-by: dependabot[bot] <support@github.com>
Signed-off-by: Jiahao XU <30436523+NobodyXu@users.noreply.github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Jiahao XU <30436523+NobodyXu@users.noreply.github.com>
2024-12-07 04:05:38 +00:00

31 lines
1,016 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: Some(Edition::E2021),
..Default::default()
},],
);
}