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