diff --git a/.gitea/workflows/ci.yml b/.gitea/workflows/ci.yml new file mode 100644 index 0000000..4126c27 --- /dev/null +++ b/.gitea/workflows/ci.yml @@ -0,0 +1,28 @@ +name: CI + +on: + push: + pull_request: + +jobs: + test: + runs-on: ubuntu-latest + + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Set up Python + uses: actions/setup-python@v5 + with: + python-version: "3.12" + + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install -r requirements.txt + + - name: Run tests + run: | + pytest -q + diff --git a/api/tests/__init__.py b/api/tests/__init__.py new file mode 100644 index 0000000..09ba083 --- /dev/null +++ b/api/tests/__init__.py @@ -0,0 +1,2 @@ +"""Tests for the FastAPI app.""" + diff --git a/api/tests/test_app.py b/api/tests/test_app.py new file mode 100644 index 0000000..779c697 --- /dev/null +++ b/api/tests/test_app.py @@ -0,0 +1,19 @@ +from fastapi.testclient import TestClient + +from api.main import app + + +client = TestClient(app) + + +def test_health() -> None: + resp = client.get("/health") + assert resp.status_code == 200 + assert resp.json() == {"status": "ok"} + + +def test_root() -> None: + resp = client.get("/") + assert resp.status_code == 200 + assert resp.json() == {"message": "FastAPI is running"} + diff --git a/requirements.txt b/requirements.txt index 364e2ee..a00c8f1 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,2 +1,4 @@ fastapi uvicorn[standard] +pytest +httpx