Skip to content

Commit

Permalink
1, Fix 'Permission denied' bug of Travis-CI command
Browse files Browse the repository at this point in the history
2,Add unittest

Fix Travis-CI command
  • Loading branch information
alexazhou committed Aug 25, 2016
1 parent 6615b1e commit fff5ab6
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 4 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ before_script:
- if [ ! -f /opt/verynginx/openresty/nginx/logs/error.log ]; then touch /opt/verynginx/openresty/nginx/logs/error.log;sudo chown nginx:nginx /opt/verynginx/openresty/nginx/logs/error.log ; fi
- sudo /opt/verynginx/openresty/nginx/sbin/nginx
- sudo /opt/verynginx/openresty/nginx/sbin/nginx -s stop
- echo -e "127.0.0.1 a.vntest.com\n127.0.0.1 b.vntest.com\n127.0.0.1 c.vntest.com" >> /etc/hosts
- echo -e "127.0.0.1 a.vntest.com\n127.0.0.1 b.vntest.com\n127.0.0.1 c.vntest.com" | sudo tee -a /etc/hosts

script:
- sudo python3 test/test.py
32 changes: 29 additions & 3 deletions test/testcase/a_3/case.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,37 @@ def test_host_equal(self):
assert r.status_code == 404
assert r.headers.get('content-type') == 'text/html'
assert 'hited' not in r.text

def test_host_not_equal(self):
pass
r = requests.get('http://a.vntest.com/testhostnotequal')
assert r.status_code == 404
assert r.headers.get('content-type') == 'text/html'
assert 'hited' not in r.text

r = requests.get('http://b.vntest.com/testhostnotequal')
assert r.status_code == 400
assert r.headers.get('content-type') == 'text/html'
assert 'hited' in r.text

def test_host_match(self):
pass
r = requests.get('http://a.vntest.com/testhostmatch')
assert r.status_code == 400
assert r.headers.get('content-type') == 'text/html'
assert 'hited' in r.text

r = requests.get('http://127.0.0.1/testhostmatch')
assert r.status_code == 404
assert r.headers.get('content-type') == 'text/html'
assert 'hited' not in r.text

def test_host_not_match(self):
pass
r = requests.get('http://a.vntest.com/testhostnotmatch')
assert r.status_code == 404
assert r.headers.get('content-type') == 'text/html'
assert 'hited' not in r.text

r = requests.get('http://127.0.0.1/testhostnotmatch')
assert r.status_code == 400
assert r.headers.get('content-type') == 'text/html'
assert 'hited' in r.text

0 comments on commit fff5ab6

Please sign in to comment.