mirror of
https://github.com/openfaas/faas.git
synced 2025-06-21 22:33:23 +00:00
Initial pop-up for new function.
This commit is contained in:
34
gateway/tests/integration/createfunction_test.go
Normal file
34
gateway/tests/integration/createfunction_test.go
Normal file
@ -0,0 +1,34 @@
|
||||
package inttests
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestCreate_ValidJson(t *testing.T) {
|
||||
reqBody := `{}`
|
||||
_, code, err := fireRequest("http://localhost:8080/system/functions", http.MethodPost, reqBody)
|
||||
|
||||
if err != nil {
|
||||
t.Log(err)
|
||||
t.Fail()
|
||||
}
|
||||
|
||||
if code != http.StatusOK {
|
||||
t.Errorf("Got HTTP code: %d, want %d\n", code, http.StatusBadRequest)
|
||||
}
|
||||
}
|
||||
|
||||
func TestCreateBadFunctionNotJson(t *testing.T) {
|
||||
reqBody := `not json`
|
||||
_, code, err := fireRequest("http://localhost:8080/system/functions", http.MethodPost, reqBody)
|
||||
|
||||
if err != nil {
|
||||
t.Log(err)
|
||||
t.Fail()
|
||||
}
|
||||
|
||||
if code != http.StatusBadRequest {
|
||||
t.Errorf("Got HTTP code: %d, want %d\n", code, http.StatusBadRequest)
|
||||
}
|
||||
}
|
@ -25,7 +25,7 @@ func fireRequestWithHeader(url string, method string, reqBody string, xheader st
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
req.Header.Set("User-Agent", "spacecount-tutorial")
|
||||
req.Header.Set("User-Agent", "go-integration")
|
||||
if len(xheader) != 0 {
|
||||
req.Header.Set("X-Function", xheader)
|
||||
}
|
||||
|
Reference in New Issue
Block a user