mirror of
https://github.com/thib8956/nginx-proxy
synced 2024-11-25 05:16:30 +00:00
TESTS: separated containers: fix indentation and remove dependency over jwilder/whoami image
This commit is contained in:
parent
85370fa31f
commit
9620be91fa
@ -17,6 +17,9 @@ class Handler(http.server.SimpleHTTPRequestHandler):
|
|||||||
elif self.path == "/port":
|
elif self.path == "/port":
|
||||||
response = "answer from port %s\n" % PORT
|
response = "answer from port %s\n" % PORT
|
||||||
self.wfile.write(response.encode())
|
self.wfile.write(response.encode())
|
||||||
|
elif self.path == "/":
|
||||||
|
response = "I'm %s\n" % os.environ['HOSTNAME']
|
||||||
|
self.wfile.write(response.encode())
|
||||||
else:
|
else:
|
||||||
self.wfile.write("No route for this path!\n".encode())
|
self.wfile.write("No route for this path!\n".encode())
|
||||||
|
|
||||||
|
@ -18,7 +18,8 @@ def nginx_tmpl():
|
|||||||
remove=True,
|
remove=True,
|
||||||
volumes=['{current_dir}:{current_dir}'.format(current_dir=script_dir)],
|
volumes=['{current_dir}:{current_dir}'.format(current_dir=script_dir)],
|
||||||
entrypoint='sh',
|
entrypoint='sh',
|
||||||
command='-xc "cp /app/nginx.tmpl {current_dir} && chmod 777 {current_dir}/nginx.tmpl"'.format(current_dir=script_dir),
|
command='-xc "cp /app/nginx.tmpl {current_dir} && chmod 777 {current_dir}/nginx.tmpl"'.format(
|
||||||
|
current_dir=script_dir),
|
||||||
stderr=True))
|
stderr=True))
|
||||||
yield
|
yield
|
||||||
logging.info("removing nginx.tmpl")
|
logging.info("removing nginx.tmpl")
|
||||||
@ -35,4 +36,3 @@ def test_forwards_to_whoami(nginx_tmpl, docker_compose, nginxproxy):
|
|||||||
assert r.status_code == 200
|
assert r.status_code == 200
|
||||||
whoami_container = docker_compose.containers.get("whoami")
|
whoami_container = docker_compose.containers.get("whoami")
|
||||||
assert r.text == "I'm %s\n" % whoami_container.id[:12]
|
assert r.text == "I'm %s\n" % whoami_container.id[:12]
|
||||||
|
|
||||||
|
@ -16,8 +16,11 @@ services:
|
|||||||
- /var/run/docker.sock:/tmp/docker.sock:ro
|
- /var/run/docker.sock:/tmp/docker.sock:ro
|
||||||
- ./nginx.tmpl:/etc/docker-gen/templates/nginx.tmpl
|
- ./nginx.tmpl:/etc/docker-gen/templates/nginx.tmpl
|
||||||
|
|
||||||
whoami:
|
web:
|
||||||
image: jwilder/whoami
|
image: web
|
||||||
container_name: whoami
|
container_name: whoami
|
||||||
|
expose:
|
||||||
|
- "80"
|
||||||
environment:
|
environment:
|
||||||
- VIRTUAL_HOST=whoami.nginx.container.docker
|
WEB_PORTS: 80
|
||||||
|
VIRTUAL_HOST: whoami.nginx.container.docker
|
@ -7,6 +7,7 @@ import pytest
|
|||||||
def versiontuple(v):
|
def versiontuple(v):
|
||||||
return tuple(map(int, (v.split("."))))
|
return tuple(map(int, (v.split("."))))
|
||||||
|
|
||||||
|
|
||||||
docker_version = docker.from_env().version()['Version']
|
docker_version = docker.from_env().version()['Version']
|
||||||
pytestmark = pytest.mark.skipif(versiontuple(docker_version) < versiontuple('1.13'),
|
pytestmark = pytest.mark.skipif(versiontuple(docker_version) < versiontuple('1.13'),
|
||||||
reason="Docker compose syntax v3 requires docker engine v1.13")
|
reason="Docker compose syntax v3 requires docker engine v1.13")
|
||||||
@ -26,7 +27,8 @@ def nginx_tmpl():
|
|||||||
remove=True,
|
remove=True,
|
||||||
volumes=['{current_dir}:{current_dir}'.format(current_dir=script_dir)],
|
volumes=['{current_dir}:{current_dir}'.format(current_dir=script_dir)],
|
||||||
entrypoint='sh',
|
entrypoint='sh',
|
||||||
command='-xc "cp /app/nginx.tmpl {current_dir} && chmod 777 {current_dir}/nginx.tmpl"'.format(current_dir=script_dir),
|
command='-xc "cp /app/nginx.tmpl {current_dir} && chmod 777 {current_dir}/nginx.tmpl"'.format(
|
||||||
|
current_dir=script_dir),
|
||||||
stderr=True))
|
stderr=True))
|
||||||
yield
|
yield
|
||||||
logging.info("removing nginx.tmpl")
|
logging.info("removing nginx.tmpl")
|
||||||
@ -43,4 +45,3 @@ def test_forwards_to_whoami(nginx_tmpl, docker_compose, nginxproxy):
|
|||||||
assert r.status_code == 200
|
assert r.status_code == 200
|
||||||
whoami_container = docker_compose.containers.get("whoami")
|
whoami_container = docker_compose.containers.get("whoami")
|
||||||
assert r.text == "I'm %s\n" % whoami_container.id[:12]
|
assert r.text == "I'm %s\n" % whoami_container.id[:12]
|
||||||
|
|
||||||
|
@ -14,11 +14,14 @@ services:
|
|||||||
- ./nginx.tmpl:/etc/docker-gen/templates/nginx.tmpl
|
- ./nginx.tmpl:/etc/docker-gen/templates/nginx.tmpl
|
||||||
- nginx_conf:/etc/nginx/conf.d
|
- nginx_conf:/etc/nginx/conf.d
|
||||||
|
|
||||||
whoami:
|
web:
|
||||||
image: jwilder/whoami
|
image: web
|
||||||
container_name: whoami
|
container_name: whoami
|
||||||
|
expose:
|
||||||
|
- "80"
|
||||||
environment:
|
environment:
|
||||||
- VIRTUAL_HOST=whoami.nginx.container.docker
|
WEB_PORTS: 80
|
||||||
|
VIRTUAL_HOST: whoami.nginx.container.docker
|
||||||
|
|
||||||
volumes:
|
volumes:
|
||||||
nginx_conf: {}
|
nginx_conf: {}
|
Loading…
Reference in New Issue
Block a user