Skip to content

Commit

Permalink
add integration tests
Browse files Browse the repository at this point in the history
  • Loading branch information
amiremohamadi committed Mar 22, 2024
1 parent b6ed756 commit 446a1f2
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 2 deletions.
18 changes: 16 additions & 2 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,24 @@ 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
cargo build
- name: Run integration tests
run: |
(./target/debug/vmessy --config config/config.toml && sleep 2) &
VMESSY_HOST='127.0.0.1' python3 -m pytest tests
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
/target
**/__pycache__
2 changes: 2 additions & 0 deletions tests/requirements-freeze.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
pytest==8.1.1
requests==2.31.0
16 changes: 16 additions & 0 deletions tests/test_integration.py
Original file line number Diff line number Diff line change
@@ -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 = ('<HTML><HEAD><meta http-equiv="content-type" content="text/html;charset=utf-8">\n'
'<TITLE>301 Moved</TITLE></HEAD><BODY>\n<H1>301 Moved</H1>\nThe document has moved\n'
'<A HREF="http://www.google.com/">here</A>.\r\n</BODY></HTML>\r\n')
assert response == expected

0 comments on commit 446a1f2

Please sign in to comment.