Skip to content
Snippets Groups Projects
Commit 4873e08d authored by Alex Ellis (OpenFaaS Ltd)'s avatar Alex Ellis (OpenFaaS Ltd) Committed by Alex Ellis
Browse files

Add test to show TransferEncoding being passed to function

parent 6a30ce1e
No related branches found
No related tags found
No related merge requests found
......@@ -26,6 +26,45 @@ func TestHandler_make(t *testing.T) {
}
}
func TestHandler_TransferEncodingPassedToFunction(t *testing.T) {
rr := httptest.NewRecorder()
body := "Message"
req, err := http.NewRequest(http.MethodPost, "/", bytes.NewBufferString(body))
req.TransferEncoding = []string{
"chunked",
}
req.ContentLength = -1
if err != nil {
t.Fatal(err)
}
config := WatchdogConfig{
faasProcess: "env",
cgiHeaders: true,
}
handler := makeRequestHandler(&config)
handler(rr, req)
required := http.StatusOK
if status := rr.Code; status != required {
t.Errorf("handler returned wrong status code - got: %v, want: %v",
status, required)
}
read, _ := ioutil.ReadAll(rr.Body)
val := string(read)
if !strings.Contains(val, `Http_ContentLength=-1`) {
t.Errorf(config.faasProcess+" should print: Http_ContentLength=-1, got: %s\n", val)
}
if !strings.Contains(val, "Http_Transfer_Encoding") {
t.Errorf(config.faasProcess+" should print: Http_Transfer_Encoding=chunked, got: %s\n", val)
}
}
func TestHandler_HasCustomHeaderInFunction_WithCgi_Mode(t *testing.T) {
rr := httptest.NewRecorder()
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment