Add option_asset! to match asset! (#4791)

This commit is contained in:
Amar Sood authored and GitHub committed 2025-10-28 11:26:21 -07:00
1 parent e656bace5c
commit 8adea41efa
5 files changed
+77 -16

No files matched your search

@@ -0,0 +1,17 @@
use manganis::{asset, option_asset, Asset};
#[test]
fn resolves_existing_asset() {
const REQUIRED: Asset = asset!("/assets/asset.txt");
const OPTIONAL: Option<Asset> = option_asset!("/assets/asset.txt");
let optional = OPTIONAL.expect("option_asset! should return Some for existing assets");
assert_eq!(optional.to_string(), REQUIRED.to_string());
}
#[test]
fn missing_asset_returns_none() {
const OPTIONAL: Option<Asset> = option_asset!("/assets/does_not_exist.txt");
assert!(OPTIONAL.is_none());
}