Skip to content

Commit

Permalink
test: add test for app
Browse files Browse the repository at this point in the history
  • Loading branch information
egvimo committed Oct 24, 2023
1 parent 07235eb commit 0889dbc
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 0 deletions.
25 changes: 25 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 httpx
- name: Install dependencies
run: pip install -r requirements.txt

- name: Test
run: pytest test_app.py

build:
name: Build
runs-on: ubuntu-latest
Expand Down
12 changes: 12 additions & 0 deletions test_app.py
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 0889dbc

Please sign in to comment.