fix: copy and move
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
from __future__ import annotations
|
||||
|
||||
import sqlite3
|
||||
import sys
|
||||
import tempfile
|
||||
import unittest
|
||||
@@ -58,6 +59,33 @@ class TaskRepositoryTest(unittest.TestCase):
|
||||
}
|
||||
)
|
||||
|
||||
def test_migrates_legacy_tasks_schema_missing_source_destination(self) -> None:
|
||||
legacy_db_path = Path(self.temp_dir.name) / "legacy.db"
|
||||
conn = sqlite3.connect(legacy_db_path)
|
||||
conn.execute(
|
||||
"""
|
||||
CREATE TABLE tasks (
|
||||
id TEXT PRIMARY KEY,
|
||||
operation TEXT NOT NULL,
|
||||
status TEXT NOT NULL,
|
||||
created_at TEXT NOT NULL
|
||||
)
|
||||
"""
|
||||
)
|
||||
conn.commit()
|
||||
conn.close()
|
||||
|
||||
repo = TaskRepository(str(legacy_db_path))
|
||||
created = repo.create_task(
|
||||
operation="move",
|
||||
source="storage1/a.txt",
|
||||
destination="storage2/a.txt",
|
||||
)
|
||||
|
||||
self.assertEqual(created["operation"], "move")
|
||||
self.assertEqual(created["source"], "storage1/a.txt")
|
||||
self.assertEqual(created["destination"], "storage2/a.txt")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
|
||||
Reference in New Issue
Block a user