pinakes-plugin-api: fix hasher usage in tests
Signed-off-by: NotAShelf <raf@notashelf.dev> Change-Id: I8ee475aef2d1f81cf6af6f5e247f5e386a6a6964
This commit is contained in:
parent
5b817e0b3e
commit
6b8444f19c
1 changed files with 35 additions and 20 deletions
|
|
@ -83,10 +83,12 @@ async fn test_plugin_context_creation() {
|
|||
let context = PluginContext {
|
||||
data_dir: PathBuf::from("/data/test-plugin"),
|
||||
cache_dir: PathBuf::from("/cache/test-plugin"),
|
||||
config: FxHashMap::from([
|
||||
config: [
|
||||
("enabled".to_string(), serde_json::json!(true)),
|
||||
("max_items".to_string(), serde_json::json!(100)),
|
||||
]),
|
||||
]
|
||||
.into_iter()
|
||||
.collect(),
|
||||
capabilities: Capabilities {
|
||||
filesystem: FilesystemCapability {
|
||||
read: vec![PathBuf::from("/data")],
|
||||
|
|
@ -165,10 +167,12 @@ async fn test_extracted_metadata_structure() {
|
|||
file_size_bytes: Some(1_500_000),
|
||||
codec: Some("h264".to_string()),
|
||||
bitrate_kbps: Some(5000),
|
||||
custom_fields: FxHashMap::from([
|
||||
custom_fields: [
|
||||
("color_space".to_string(), serde_json::json!("sRGB")),
|
||||
("orientation".to_string(), serde_json::json!(90)),
|
||||
]),
|
||||
]
|
||||
.into_iter()
|
||||
.collect(),
|
||||
tags: vec!["test".to_string(), "document".to_string()],
|
||||
};
|
||||
|
||||
|
|
@ -183,10 +187,12 @@ async fn test_extracted_metadata_structure() {
|
|||
async fn test_search_query_serialization() {
|
||||
let query = SearchQuery {
|
||||
query_text: "nature landscape".to_string(),
|
||||
filters: FxHashMap::from([
|
||||
filters: [
|
||||
("type".to_string(), serde_json::json!("image")),
|
||||
("year".to_string(), serde_json::json!(2023)),
|
||||
]),
|
||||
]
|
||||
.into_iter()
|
||||
.collect(),
|
||||
limit: 50,
|
||||
offset: 0,
|
||||
};
|
||||
|
|
@ -330,10 +336,12 @@ async fn test_event_serialization() {
|
|||
let event = Event {
|
||||
event_type: EventType::MediaImported,
|
||||
timestamp: "2024-01-15T10:00:00Z".to_string(),
|
||||
data: FxHashMap::from([
|
||||
data: [
|
||||
("path".to_string(), serde_json::json!("/media/test.jpg")),
|
||||
("size".to_string(), serde_json::json!(1024)),
|
||||
]),
|
||||
]
|
||||
.into_iter()
|
||||
.collect(),
|
||||
};
|
||||
|
||||
let serialized = serde_json::to_string(&event).unwrap();
|
||||
|
|
@ -348,10 +356,12 @@ async fn test_http_request_serialization() {
|
|||
let request = HttpRequest {
|
||||
method: "GET".to_string(),
|
||||
url: "https://api.example.com/data".to_string(),
|
||||
headers: FxHashMap::from([
|
||||
headers: [
|
||||
("Authorization".to_string(), "Bearer token".to_string()),
|
||||
("Content-Type".to_string(), "application/json".to_string()),
|
||||
]),
|
||||
]
|
||||
.into_iter()
|
||||
.collect(),
|
||||
body: None,
|
||||
};
|
||||
|
||||
|
|
@ -367,10 +377,9 @@ async fn test_http_request_serialization() {
|
|||
async fn test_http_response_serialization() {
|
||||
let response = HttpResponse {
|
||||
status: 200,
|
||||
headers: FxHashMap::from([(
|
||||
"Content-Type".to_string(),
|
||||
"application/json".to_string(),
|
||||
)]),
|
||||
headers: [("Content-Type".to_string(), "application/json".to_string())]
|
||||
.into_iter()
|
||||
.collect(),
|
||||
body: b"{\"success\": true}".to_vec(),
|
||||
};
|
||||
|
||||
|
|
@ -387,10 +396,12 @@ async fn test_log_message_serialization() {
|
|||
level: LogLevel::Info,
|
||||
target: "plugin::metadata".to_string(),
|
||||
message: "Metadata extraction complete".to_string(),
|
||||
fields: FxHashMap::from([
|
||||
fields: [
|
||||
("file_count".to_string(), "42".to_string()),
|
||||
("duration_ms".to_string(), "150".to_string()),
|
||||
]),
|
||||
]
|
||||
.into_iter()
|
||||
.collect(),
|
||||
};
|
||||
|
||||
let serialized = serde_json::to_string(&message).unwrap();
|
||||
|
|
@ -454,10 +465,12 @@ async fn test_search_index_item_serialization() {
|
|||
"photos".to_string(),
|
||||
],
|
||||
media_type: "image/jpeg".to_string(),
|
||||
metadata: FxHashMap::from([
|
||||
metadata: [
|
||||
("camera".to_string(), serde_json::json!("Canon EOS R5")),
|
||||
("location".to_string(), serde_json::json!("Beach")),
|
||||
]),
|
||||
]
|
||||
.into_iter()
|
||||
.collect(),
|
||||
};
|
||||
|
||||
let serialized = serde_json::to_string(&item).unwrap();
|
||||
|
|
@ -475,10 +488,12 @@ async fn test_health_status_variants() {
|
|||
let healthy = HealthStatus {
|
||||
healthy: true,
|
||||
message: Some("All systems operational".to_string()),
|
||||
metrics: FxHashMap::from([
|
||||
metrics: [
|
||||
("items_processed".to_string(), 1000.0),
|
||||
("avg_process_time_ms".to_string(), 45.5),
|
||||
]),
|
||||
]
|
||||
.into_iter()
|
||||
.collect(),
|
||||
};
|
||||
assert!(healthy.healthy);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue