forked from Furumi/furumi-web
Test that Retry unmatched is refused for other users and unfinished imports
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
2c17c9e4df
commit
22e5b515aa
1 file changed
+54
-1
@@ -27,7 +27,7 @@ use super::providers::{
|
||||
use super::resolver::{FederationAccess, NetworkLimits};
|
||||
use super::store::{
|
||||
self, CancelOutcome, ChooseOutcome, Control, CreateImportError, DeleteOutcome, FinishOutcome,
|
||||
ItemFilter, NewImport, NewItem, NewPlaylist, ReauthOutcome, ReauthTarget,
|
||||
ItemFilter, NewImport, NewItem, NewPlaylist, ReauthOutcome, ReauthTarget, ResyncOutcome,
|
||||
};
|
||||
use crate::config::AppConfig;
|
||||
use crate::federation::client::{CatalogPeers, CatalogStream};
|
||||
@@ -350,6 +350,59 @@ async fn library_import_storage_is_isolated_per_user() {
|
||||
store::delete_import(pool, 2, id).await.unwrap(),
|
||||
DeleteOutcome::NotFound
|
||||
);
|
||||
// An unmatched entry shows whether a refused retry reset anything.
|
||||
sqlx::query(
|
||||
"UPDATE furumusic__library_import_item SET resolution_status = 'unmatched'
|
||||
WHERE id = (SELECT min(i.id) FROM furumusic__library_import_item i
|
||||
JOIN furumusic__library_import_playlist p ON p.id = i.import_playlist_id
|
||||
WHERE p.import_id = $1 AND i.resolution_status = 'pending')",
|
||||
)
|
||||
.bind(id)
|
||||
.execute(pool)
|
||||
.await
|
||||
.unwrap();
|
||||
let statuses = "SELECT string_agg(i.resolution_status, ',' ORDER BY i.id)
|
||||
FROM furumusic__library_import_item i
|
||||
JOIN furumusic__library_import_playlist p ON p.id = i.import_playlist_id
|
||||
WHERE p.import_id = $1";
|
||||
let before: String = db.scalar(statuses, id).await;
|
||||
assert!(before.contains("unmatched"));
|
||||
assert_eq!(
|
||||
store::request_resync(pool, 2, id, Some(true))
|
||||
.await
|
||||
.unwrap(),
|
||||
ResyncOutcome::NotFound
|
||||
);
|
||||
assert_eq!(db.status(id).await, "queued");
|
||||
assert_eq!(db.scalar::<String>(statuses, id).await, before);
|
||||
// Retry waits until the import is finished, whatever it is waiting for.
|
||||
for status in ["queued", "running", "needs_reauth"] {
|
||||
sqlx::query("UPDATE furumusic__library_import SET status = $2 WHERE id = $1")
|
||||
.bind(id)
|
||||
.bind(status)
|
||||
.execute(pool)
|
||||
.await
|
||||
.unwrap();
|
||||
assert_eq!(
|
||||
store::request_resync(pool, 1, id, None).await.unwrap(),
|
||||
ResyncOutcome::NotFinished,
|
||||
"{status}"
|
||||
);
|
||||
assert_eq!(db.status(id).await, status);
|
||||
assert_eq!(db.scalar::<String>(statuses, id).await, before);
|
||||
}
|
||||
sqlx::query("UPDATE furumusic__library_import SET status = 'queued' WHERE id = $1")
|
||||
.bind(id)
|
||||
.execute(pool)
|
||||
.await
|
||||
.unwrap();
|
||||
sqlx::query(
|
||||
"UPDATE furumusic__library_import_item SET resolution_status = 'pending'
|
||||
WHERE resolution_status = 'unmatched'",
|
||||
)
|
||||
.execute(pool)
|
||||
.await
|
||||
.unwrap();
|
||||
assert_eq!(db.status(id).await, "queued");
|
||||
|
||||
// Entries keep source order and repeats; pages continue after the cursor.
|
||||
|
||||
Reference in new issue
Block a user