Skip to content

Commit cdb82b4

Browse files
LucasRoesleralexellis
authored andcommitted
Document how to control the testing
**What** - Add a section to the README explaining how to use the new build args to control the test step. Signed-off-by: Lucas Roesler <[email protected]>
1 parent 91271bc commit cdb82b4

File tree

1 file changed

+28
-2
lines changed

1 file changed

+28
-2
lines changed

README.md

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ The function handler is passed two arguments, *event* and *context*.
149149
150150
## Response Bodies
151151
152-
By default, the template will automatically attempt to set the correct Content-Type header for you based on the type of response.
152+
By default, the template will automatically attempt to set the correct Content-Type header for you based on the type of response.
153153
154154
For example, returning a dict object type will automatically attach the header `Content-Type: application/json` and returning a string type will automatically attach the `Content-Type: text/html, charset=utf-8` for you.
155155
@@ -196,7 +196,7 @@ def handle(event, context):
196196
},
197197
"headers": {
198198
"Location": "https://www.example.com/"
199-
}
199+
}
200200
}
201201
```
202202
### Accessing Event Data
@@ -242,3 +242,29 @@ def handle(event, context):
242242
}
243243
}
244244
```
245+
246+
247+
## Testing
248+
The `python3` templates will run `pytest` using `tox` during the `faas-cli build`. There are several options for controlling this.
249+
250+
### Disabling testing
251+
The template exposes the build arg `TEST_ENABLED`. You can completely disable testing during build by passing the following flag to the CLI
252+
253+
```sh
254+
--build-arg 'TEST_ENABLED=false'
255+
```
256+
257+
You can also set it permanently in your stack.yaml, see the [YAML reference in the docs](https://docs.openfaas.com/reference/yaml/#function-build-args-build-args).
258+
259+
### Changing the test configuration
260+
The template creates a default `tox.ini` file, modifying this file can completely control what happens during the test. You can change the test command, for example switching to `nose`. See the [tox docs](https://tox.readthedocs.io/en/latest/index.html) for more details and examples.
261+
262+
### Changing the test command
263+
If you don't want to use `tox` at all, you can also change the test command that is used. The template exposes the build arg `TEST_COMMAND`. You can override the test command during build by passing the following flag to the CLI
264+
265+
```sh
266+
--build-arg 'TEST_COMMAND=bash test.sh'
267+
```
268+
Setting the command to any other executable in the image or any scripts you have in your function.
269+
270+
You can also set it permanently in your stack.yaml, see the [YAML reference in the docs](https://docs.openfaas.com/reference/yaml/#function-build-args-build-args).

0 commit comments

Comments
 (0)