Add a script to do all the work of running tests.
This commit is contained in:
parent
d7421fc49f
commit
cb38e8118e
2 changed files with 53 additions and 3 deletions
|
@ -24,6 +24,4 @@ docker-compose up
|
||||||
|
|
||||||
# Run the E2E tests:
|
# Run the E2E tests:
|
||||||
|
|
||||||
(after `docker-compose up`)
|
`./run_tests.py`
|
||||||
`docker exec themotte bash -c "cd service && python3 -m pytest -s"`
|
|
||||||
|
|
||||||
|
|
52
run_tests.py
Executable file
52
run_tests.py
Executable file
|
@ -0,0 +1,52 @@
|
||||||
|
#!/usr/bin/python3
|
||||||
|
|
||||||
|
import subprocess
|
||||||
|
import sys
|
||||||
|
|
||||||
|
# we want to leave the container in whatever state it currently is, so check to see if it's running
|
||||||
|
docker_inspect = subprocess.run([
|
||||||
|
"docker",
|
||||||
|
"container",
|
||||||
|
"inspect",
|
||||||
|
"-f", "{{.State.Status}}",
|
||||||
|
"themotte",
|
||||||
|
],
|
||||||
|
capture_output = True,
|
||||||
|
).stdout.decode("utf-8").strip()
|
||||||
|
|
||||||
|
was_running = docker_inspect == "running"
|
||||||
|
|
||||||
|
# update containers, just in case they're out of date
|
||||||
|
if was_running:
|
||||||
|
print("Updating containers . . .")
|
||||||
|
else:
|
||||||
|
print("Starting containers . . .")
|
||||||
|
subprocess.run([
|
||||||
|
"docker-compose",
|
||||||
|
"up",
|
||||||
|
"--build",
|
||||||
|
"-d",
|
||||||
|
],
|
||||||
|
check = True,
|
||||||
|
)
|
||||||
|
|
||||||
|
# run the test
|
||||||
|
print("Running test . . .")
|
||||||
|
result = subprocess.run([
|
||||||
|
"docker",
|
||||||
|
"exec",
|
||||||
|
"themotte",
|
||||||
|
"bash", "-c", "cd service && python3 -m pytest -s"
|
||||||
|
])
|
||||||
|
|
||||||
|
if not was_running:
|
||||||
|
# shut down, if we weren't running in the first place
|
||||||
|
print("Shutting down containers . . .")
|
||||||
|
subprocess.run([
|
||||||
|
"docker-compose",
|
||||||
|
"stop",
|
||||||
|
],
|
||||||
|
check = True,
|
||||||
|
)
|
||||||
|
|
||||||
|
sys.exit(result.returncode)
|
Loading…
Add table
Add a link
Reference in a new issue