28 lines
946 B
Python
28 lines
946 B
Python
import sqlite3
|
|
import tempfile
|
|
from pathlib import Path
|
|
from aider_gitea.__main__ import save_issue_to_sqlite, load_issue_from_sqlite
|
|
|
|
def test_save_and_load_issue():
|
|
issue_number = "123"
|
|
issue_title = "Test Issue"
|
|
issue_description = "This is a test issue."
|
|
|
|
with tempfile.TemporaryDirectory() as tmpdirname:
|
|
db_path = Path(tmpdirname) / "issues.db"
|
|
|
|
# Save issue to SQLite
|
|
save_issue_to_sqlite(issue_number, issue_title, issue_description, db_path)
|
|
|
|
# Load issue from SQLite
|
|
loaded_title, loaded_description = load_issue_from_sqlite(issue_number, db_path)
|
|
|
|
assert loaded_title == issue_title
|
|
assert loaded_description == issue_description
|
|
|
|
# Test loading a non-existent issue
|
|
try:
|
|
load_issue_from_sqlite("999", db_path)
|
|
except ValueError as e:
|
|
assert str(e) == "Issue 999 not found in the database."
|