import sys
from pathlib import Path

# The meshy package lives at src/ (imported as "meshy.*" by the installed app).
# For tests, make "import meshy.storage" work by pointing at src's parent
# with src aliased as "meshy" via a symlink-free approach.
_src = Path(__file__).resolve().parent.parent / "src"
if str(_src.parent) not in sys.path:
    sys.path.insert(0, str(_src.parent))
# Register src/ as the "meshy" package
import types

if "meshy" not in sys.modules:
    pkg = types.ModuleType("meshy")
    pkg.__path__ = [str(_src)]
    pkg.__package__ = "meshy"
    sys.modules["meshy"] = pkg

import pytest
from meshy.storage import Storage


@pytest.fixture
def storage():
    s = Storage(db_path=":memory:")
    yield s
    s.close()
