From 89376298c871df80b537b1f8982e4ec3f4ea7bc8 Mon Sep 17 00:00:00 2001 From: Amir Mohammadi Date: Fri, 22 Mar 2024 18:09:53 +0330 Subject: [PATCH] add integration tests --- .github/workflows/ci.yaml | 16 ++++++++++++++-- .gitignore | 1 + tests/requirements-freeze.txt | 2 ++ tests/test_integration.py | 16 ++++++++++++++++ 4 files changed, 33 insertions(+), 2 deletions(-) create mode 100644 tests/requirements-freeze.txt create mode 100644 tests/test_integration.py diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index b356ab2..198c32f 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -10,10 +10,22 @@ env: CARGO_TERM_COLOR: always jobs: - test: + unit-test: runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 - - name: unit tests + - name: Run unit tests run: cargo test --verbose + + integration-test: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v3 + - name: Install dependencies + run: python -m pip install -r tests/requirements-freeze.txt + - name: Run service + run: docker-compose up -d + - name: Run integration tests + run: VMESSY_HOST='127.0.0.1' python3 -m pytest tests diff --git a/.gitignore b/.gitignore index ea8c4bf..a4a44d3 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ /target +**/__pycache__ diff --git a/tests/requirements-freeze.txt b/tests/requirements-freeze.txt new file mode 100644 index 0000000..85b7b17 --- /dev/null +++ b/tests/requirements-freeze.txt @@ -0,0 +1,2 @@ +pytest==8.1.1 +requests==2.31.0 diff --git a/tests/test_integration.py b/tests/test_integration.py new file mode 100644 index 0000000..507d33f --- /dev/null +++ b/tests/test_integration.py @@ -0,0 +1,16 @@ +import requests +import os + +VMESSY_HOST = os.environ.get("VMESSY_HOST", "localhost") +VMESSY_PORT = 1090 + +def test_basic_response(): + response = requests.get('http://google.com', allow_redirects=False, proxies={ + 'http': f'http://{VMESSY_HOST}:{VMESSY_PORT}', + }).text + + expected = ('\n' + '301 Moved\n

301 Moved

\nThe document has moved\n' + 'here.\r\n\r\n') + assert response == expected +