pinakes-core: update remaining modules and tests

Signed-off-by: NotAShelf <raf@notashelf.dev>
Change-Id: I9e0ff5ea33a5cf697473423e88f167ce6a6a6964
This commit is contained in:
raf 2026-03-08 00:42:29 +03:00
commit 3d9f8933d2
Signed by: NotAShelf
GPG key ID: 29D95B64378DB4BF
44 changed files with 1207 additions and 578 deletions

View file

@ -161,7 +161,7 @@ fn test_book_cover_generation() {
// Verify all cover files exist
for (size, path) in &covers {
assert!(path.exists(), "Cover {:?} should exist at {:?}", size, path);
assert!(path.exists(), "Cover {size:?} should exist at {path:?}");
}
}
@ -176,13 +176,10 @@ async fn test_openlibrary_isbn_fetch() {
// Should either succeed or fail gracefully
// We don't assert success because network might not be available
match result {
Ok(book) => {
assert!(book.title.is_some());
},
Err(_) => {
// Network error or book not found - acceptable in tests
},
if let Ok(book) = result {
assert!(book.title.is_some());
} else {
// Network error or book not found - acceptable in tests
}
}
@ -195,14 +192,11 @@ async fn test_googlebooks_isbn_fetch() {
// Use a known ISBN
let result = client.fetch_by_isbn("9780547928227").await;
match result {
Ok(books) => {
if !books.is_empty() {
assert!(books[0].volume_info.title.is_some());
}
},
Err(_) => {
// Network error - acceptable in tests
},
if let Ok(books) = result {
if !books.is_empty() {
assert!(books[0].volume_info.title.is_some());
}
} else {
// Network error - acceptable in tests
}
}

View file

@ -158,13 +158,13 @@ async fn test_large_directory_performance() {
storage.add_root_dir(root_dir.clone()).await.unwrap();
for i in 0..1000 {
let file_path = root_dir.join(format!("file_{}.mp3", i));
fs::write(&file_path, format!("content {}", i)).unwrap();
let file_path = root_dir.join(format!("file_{i}.mp3"));
fs::write(&file_path, format!("content {i}")).unwrap();
}
for i in 0..500 {
let file_path = root_dir.join(format!("file_{}.mp3", i));
let item = create_test_media_item(file_path, &format!("hash_{}", i));
let file_path = root_dir.join(format!("file_{i}.mp3"));
let item = create_test_media_item(file_path, &format!("hash_{i}"));
storage.insert_media(&item).await.unwrap();
}
@ -174,8 +174,7 @@ async fn test_large_directory_performance() {
assert!(
elapsed.as_secs() < 5,
"Detection took too long: {:?}",
elapsed
"Detection took too long: {elapsed:?}"
);
assert_eq!(report.untracked_paths.len(), 500);

View file

@ -6,7 +6,7 @@ mod common;
fn create_test_note_content(num_links: usize) -> String {
let mut content = String::from("# Test Note\n\n");
for i in 0..num_links {
content.push_str(&format!("Link {}: [[note_{}]]\n", i, i));
content.push_str(&format!("Link {i}: [[note_{i}]]\n"));
}
content
}

View file

@ -121,7 +121,7 @@ async fn test_delete_user_sessions() {
// Create multiple sessions for the same user
for i in 0..3 {
let session = SessionData {
session_token: format!("token_{}", i),
session_token: format!("token_{i}"),
user_id: None,
username: "testuser".to_string(),
role: "viewer".to_string(),
@ -152,7 +152,7 @@ async fn test_delete_user_sessions() {
for i in 0..3 {
assert!(
storage
.get_session(&format!("token_{}", i))
.get_session(&format!("token_{i}"))
.await
.unwrap()
.is_none()
@ -217,7 +217,7 @@ async fn test_list_active_sessions() {
// Create active sessions for different users
for i in 0..3 {
let session = SessionData {
session_token: format!("user1_token_{}", i),
session_token: format!("user1_token_{i}"),
user_id: None,
username: "user1".to_string(),
role: "viewer".to_string(),
@ -230,7 +230,7 @@ async fn test_list_active_sessions() {
for i in 0..2 {
let session = SessionData {
session_token: format!("user2_token_{}", i),
session_token: format!("user2_token_{i}"),
user_id: None,
username: "user2".to_string(),
role: "admin".to_string(),
@ -279,9 +279,9 @@ async fn test_concurrent_session_operations() {
let storage = storage.clone();
let handle = tokio::spawn(async move {
let session = SessionData {
session_token: format!("concurrent_{}", i),
session_token: format!("concurrent_{i}"),
user_id: None,
username: format!("user{}", i),
username: format!("user{i}"),
role: "viewer".to_string(),
created_at: now,
expires_at: now + chrono::Duration::hours(24),
@ -301,7 +301,7 @@ async fn test_concurrent_session_operations() {
for i in 0..10 {
assert!(
storage
.get_session(&format!("concurrent_{}", i))
.get_session(&format!("concurrent_{i}"))
.await
.unwrap()
.is_some()