pinakes-plugin-api: expand test coverage; fix merge conflicts
Signed-off-by: NotAShelf <raf@notashelf.dev> Change-Id: I34e7c6d382ab7f4b6cf98ede9b7116056a6a6964
This commit is contained in:
parent
152356ce9f
commit
3abfe6a79b
9 changed files with 631 additions and 128 deletions
67
crates/pinakes-plugin-api/tests/validate.rs
Normal file
67
crates/pinakes-plugin-api/tests/validate.rs
Normal file
|
|
@ -0,0 +1,67 @@
|
|||
use pinakes_plugin_api::PluginManifest;
|
||||
use std::path::PathBuf;
|
||||
|
||||
#[test]
|
||||
fn test_markdown_metadata_manifest() {
|
||||
let manifest_path = PathBuf::from(env!("CARGO_MANIFEST_DIR"))
|
||||
.parent()
|
||||
.unwrap()
|
||||
.parent()
|
||||
.unwrap()
|
||||
.join("examples/plugins/markdown-metadata/plugin.toml");
|
||||
|
||||
let manifest = PluginManifest::from_file(&manifest_path)
|
||||
.expect("Failed to parse markdown-metadata plugin.toml");
|
||||
|
||||
assert_eq!(manifest.plugin.name, "markdown-metadata");
|
||||
assert_eq!(manifest.plugin.version, "1.0.0");
|
||||
assert_eq!(manifest.plugin.api_version, "1.0");
|
||||
assert_eq!(manifest.plugin.kind, vec!["metadata_extractor"]);
|
||||
assert_eq!(manifest.plugin.binary.wasm, "markdown_metadata.wasm");
|
||||
|
||||
// Validate capabilities
|
||||
let caps = manifest.to_capabilities();
|
||||
assert_eq!(caps.filesystem.read.len(), 0);
|
||||
assert_eq!(caps.filesystem.write.len(), 0);
|
||||
assert!(!caps.network.enabled);
|
||||
|
||||
// Validate config
|
||||
assert!(manifest.config.contains_key("extract_tags"));
|
||||
assert!(manifest.config.contains_key("parse_yaml"));
|
||||
assert!(manifest.config.contains_key("max_file_size"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_heif_support_manifest() {
|
||||
let manifest_path = PathBuf::from(env!("CARGO_MANIFEST_DIR"))
|
||||
.parent()
|
||||
.unwrap()
|
||||
.parent()
|
||||
.unwrap()
|
||||
.join("examples/plugins/heif-support/plugin.toml");
|
||||
|
||||
let manifest = PluginManifest::from_file(&manifest_path)
|
||||
.expect("Failed to parse heif-support plugin.toml");
|
||||
|
||||
assert_eq!(manifest.plugin.name, "heif-support");
|
||||
assert_eq!(manifest.plugin.version, "1.0.0");
|
||||
assert_eq!(manifest.plugin.api_version, "1.0");
|
||||
assert_eq!(
|
||||
manifest.plugin.kind,
|
||||
vec!["media_type", "metadata_extractor", "thumbnail_generator"]
|
||||
);
|
||||
assert_eq!(manifest.plugin.binary.wasm, "heif_support.wasm");
|
||||
|
||||
// Validate capabilities
|
||||
let caps = manifest.to_capabilities();
|
||||
assert_eq!(caps.filesystem.read.len(), 1);
|
||||
assert_eq!(caps.filesystem.write.len(), 1);
|
||||
assert!(!caps.network.enabled);
|
||||
assert_eq!(caps.max_memory_bytes, Some(256 * 1024 * 1024)); // 256MB
|
||||
assert_eq!(caps.max_cpu_time_ms, Some(30 * 1000)); // 30 seconds
|
||||
|
||||
// Validate config
|
||||
assert!(manifest.config.contains_key("extract_exif"));
|
||||
assert!(manifest.config.contains_key("generate_thumbnails"));
|
||||
assert!(manifest.config.contains_key("thumbnail_quality"));
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue