fn: support for functions testing (#379)

* fn: add test framework

* fn: make routes creation smarter

* fn: add testframework examples

* fn: remove unnecessary dependency

* fn: update doc

* fn: fix consistenty between runff, runlocaltest and runremotetest
This commit is contained in:
C Cirello
2016-12-05 17:05:06 +01:00
committed by Seif Lotfy سيف لطفي
parent 49cc0f6533
commit 28f713ed11
17 changed files with 442 additions and 51 deletions

View File

@@ -27,7 +27,8 @@ build:
route updated to use it.
`path` (optional) allows you to overwrite the calculated route from the path
position. You may use it to override the calculated route.
position. You may use it to override the calculated route. If you plan to use
`fn test --remote=""`, this is mandatory.
`version` represents current version of the function. When deploying, it is
appended to the image as a tag.
@@ -47,4 +48,32 @@ during functions execution.
`build` (optional) is an array of shell calls which are used to helping building
the image. These calls are executed before `fn` calls `docker build` and
`docker push`.
`docker push`.
## Testing functions
`tests` (optional) is an array of tests that can be used to valid functions both
locally and remotely. It has the following structure
```yaml
tests:
- name: envvar
in: "inserted stdin"
out: "expected stdout"
err: "expected stderr"
env:
envvar: trololo
```
`in` (optional) is a string that is going to be sent to the file's declared
function.
`out` (optional) is the expected output for this function test. It is present
both in local and remote executions.
`err` (optional) similar to `out`, however it read from `stderr`. It is only
available for local machine tests.
`env` (optional) is a map of environment variables that are injected during
tests.