Skip to content

Commit

Permalink
Add build arg to control the test command
Browse files Browse the repository at this point in the history
**What**
- Add a build arg TEST_COMMAND that allows the
  developer to set the exact test command that
  should be executed. When set to `off` the tests
  will be skipped

Signed-off-by: Lucas Roesler <[email protected]>
  • Loading branch information
LucasRoesler authored and alexellis committed Mar 25, 2021
1 parent 5a54c92 commit 19512d2
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
8 changes: 7 additions & 1 deletion template/python3-flask/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,13 @@ USER root

COPY function/ .
RUN chown -R app:app ../
RUN tox -l == 0 && tox

ARG TEST_COMMAND=tox
RUN if [ "x$TEST_COMMAND" = "xoff" ]; then \
echo "skipping tests";\
else \
eval "$TEST_COMMAND"; \
fi

WORKDIR /home/app/

Expand Down
5 changes: 3 additions & 2 deletions template/python3-flask/function/handler_test.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
from .handler import handle

# Test your handler here
# To disable testing, you need to update the
# tox.ini file, in addition to deleting this file.

# To disable testing, you can set the build_arg `TEST_COMMAND=off` on the CLI or in your stack.yml
# https://docs.openfaas.com/reference/yaml/#function-build-args-build-args

def test_handle():
# assert handle("input") == "input"
Expand Down

0 comments on commit 19512d2

Please sign in to comment.