You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
**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]>
Copy file name to clipboardExpand all lines: README.md
+28-2Lines changed: 28 additions & 2 deletions
Original file line number
Diff line number
Diff line change
@@ -149,7 +149,7 @@ The function handler is passed two arguments, *event* and *context*.
149
149
150
150
## Response Bodies
151
151
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.
153
153
154
154
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.
155
155
@@ -196,7 +196,7 @@ def handle(event, context):
196
196
},
197
197
"headers": {
198
198
"Location": "https://www.example.com/"
199
-
}
199
+
}
200
200
}
201
201
```
202
202
### Accessing Event Data
@@ -242,3 +242,29 @@ def handle(event, context):
242
242
}
243
243
}
244
244
```
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