"""Quick test to verify SQLite setup works."""
import sys
sys.path.insert(0, '.')

import asyncio
from common.sqlite_client import init_sqlite, sqlite_client

async def test():
    print("Connecting to SQLite...")
    await init_sqlite()
    print("Database initialized")

    # Test insert
    await sqlite_client.execute(
        "INSERT INTO cuccu_users (email, nickname, username) VALUES (?, ?, ?)",
        ("test@example.com", "Test User", "testuser")
    )
    print("Inserted test user")

    # Test query
    row = await sqlite_client.fetch_one(
        "SELECT * FROM cuccu_users WHERE email = ?",
        ("test@example.com",)
    )
    if row:
        print(f"Found user: id={row['id']}, email={row['email']}")
    else:
        print("User not found")

    # Test memos table
    await sqlite_client.execute(
        "INSERT INTO cuccu_memos (uid, creator_id, content, visibility) VALUES (?, ?, ?, ?)",
        ("test123", "1", "Test memo content", "PUBLIC")
    )
    print("Inserted test memo")

    rows = await sqlite_client.fetch_all("SELECT * FROM cuccu_memos", ())
    print(f"Total memos: {len(rows)}")

    print("\nAll tests passed!")

if __name__ == "__main__":
    asyncio.run(test())
