mirror of
https://github.com/fnproject/fn.git
synced 2022-10-28 21:29:17 +03:00
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:
committed by
Seif Lotfy سيف لطفي
parent
49cc0f6533
commit
28f713ed11
16
examples/testframework/local/README.md
Normal file
16
examples/testframework/local/README.md
Normal file
@@ -0,0 +1,16 @@
|
||||
# Example of IronFunctions test framework - running functions locally
|
||||
|
||||
This example will show you how to run a test suite on a function.
|
||||
|
||||
```sh
|
||||
# build the test image (testframework:0.0.1)
|
||||
fn build
|
||||
# test it
|
||||
fn test
|
||||
```
|
||||
|
||||
Alternatively, you can force a rebuild before the test suite with:
|
||||
```sh
|
||||
# build and test it
|
||||
fn test -b
|
||||
```
|
||||
14
examples/testframework/local/func.go
Normal file
14
examples/testframework/local/func.go
Normal file
@@ -0,0 +1,14 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
)
|
||||
|
||||
func main() {
|
||||
envvar := os.Getenv("HEADER_ENVVAR")
|
||||
if envvar != "" {
|
||||
fmt.Println("HEADER_ENVVAR:", envvar)
|
||||
}
|
||||
fmt.Println("hw")
|
||||
}
|
||||
15
examples/testframework/local/func.yaml
Normal file
15
examples/testframework/local/func.yaml
Normal file
@@ -0,0 +1,15 @@
|
||||
name: testframework
|
||||
version: 0.0.1
|
||||
runtime: go
|
||||
entrypoint: ./func
|
||||
path: /tests
|
||||
tests:
|
||||
- name: simple
|
||||
out: |
|
||||
hw
|
||||
- name: envvar
|
||||
out: |
|
||||
HEADER_ENVVAR: trololo
|
||||
hw
|
||||
env:
|
||||
envvar: trololo
|
||||
14
examples/testframework/remote/README.md
Normal file
14
examples/testframework/remote/README.md
Normal file
@@ -0,0 +1,14 @@
|
||||
# Example of IronFunctions test framework - running functions remotely
|
||||
|
||||
This example will show you how to run a test suite on a function.
|
||||
|
||||
```sh
|
||||
# build the test image (iron/functions-testframework:0.0.1)
|
||||
fn build
|
||||
# push it
|
||||
fn push
|
||||
# create a route for the testframework
|
||||
fn routes create testframework
|
||||
# test it
|
||||
fn test --remote testframework
|
||||
```
|
||||
14
examples/testframework/remote/func.go
Normal file
14
examples/testframework/remote/func.go
Normal file
@@ -0,0 +1,14 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
)
|
||||
|
||||
func main() {
|
||||
envvar := os.Getenv("HEADER_ENVVAR")
|
||||
if envvar != "" {
|
||||
fmt.Println("HEADER_ENVVAR:", envvar)
|
||||
}
|
||||
fmt.Println("hw")
|
||||
}
|
||||
15
examples/testframework/remote/func.yaml
Normal file
15
examples/testframework/remote/func.yaml
Normal file
@@ -0,0 +1,15 @@
|
||||
name: iron/functions-testframework
|
||||
version: 0.0.1
|
||||
runtime: go
|
||||
entrypoint: ./func
|
||||
path: /tests
|
||||
tests:
|
||||
- name: simple
|
||||
out: |
|
||||
hw
|
||||
- name: envvar
|
||||
out: |
|
||||
HEADER_ENVVAR: trololo
|
||||
hw
|
||||
env:
|
||||
envvar: trololo
|
||||
Reference in New Issue
Block a user