Skip to content

Commit 19512d2

Browse files
LucasRoesleralexellis
authored andcommitted
Add build arg to control the test command
**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 <roesler.lucas@gmail.com>
1 parent 5a54c92 commit 19512d2

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

template/python3-flask/Dockerfile

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,13 @@ USER root
3939

4040
COPY function/ .
4141
RUN chown -R app:app ../
42-
RUN tox -l == 0 && tox
42+
43+
ARG TEST_COMMAND=tox
44+
RUN if [ "x$TEST_COMMAND" = "xoff" ]; then \
45+
echo "skipping tests";\
46+
else \
47+
eval "$TEST_COMMAND"; \
48+
fi
4349

4450
WORKDIR /home/app/
4551

template/python3-flask/function/handler_test.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
from .handler import handle
22

33
# Test your handler here
4-
# To disable testing, you need to update the
5-
# tox.ini file, in addition to deleting this file.
4+
5+
# To disable testing, you can set the build_arg `TEST_COMMAND=off` on the CLI or in your stack.yml
6+
# https://docs.openfaas.com/reference/yaml/#function-build-args-build-args
67

78
def test_handle():
89
# assert handle("input") == "input"

0 commit comments

Comments
 (0)