diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index f29fd5a..3407dbe 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -33,6 +33,31 @@ jobs: - name: Lint run: pylint app.py apt_info.py + test: + name: Test + runs-on: ubuntu-latest + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Set up Python 3 + id: setup-python + uses: actions/setup-python@v4 + with: + python-version: "3.x" + + - name: Prepare + run: | + sudo apt install libapt-pkg-dev + pip install pytest httpx + + - name: Install dependencies + run: pip install -r requirements.txt + + - name: Test + run: pytest test_app.py + build: name: Build runs-on: ubuntu-latest diff --git a/test_app.py b/test_app.py new file mode 100644 index 0000000..70bae96 --- /dev/null +++ b/test_app.py @@ -0,0 +1,12 @@ +from fastapi.testclient import TestClient +from app import app + +client = TestClient(app) + + +def test_read_main(): + response = client.get("/metrics") + assert response.status_code == 200 + assert "# HELP" in response.text + assert "# TYPE" in response.text + assert "apt_" in response.text