From 03848322992c0e075eb423b9809cd4f7bf4ef54c Mon Sep 17 00:00:00 2001 From: Matias Pan Date: Thu, 4 Apr 2019 17:18:26 -0300 Subject: [PATCH] Add unit tests for new env variable Signed-off-by: Matias Pan --- watchdog/handler.go | 2 +- watchdog/requesthandler_test.go | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/watchdog/handler.go b/watchdog/handler.go index 76402cc2..ac487b8d 100644 --- a/watchdog/handler.go +++ b/watchdog/handler.go @@ -228,7 +228,7 @@ func getAdditionalEnvs(config *WatchdogConfig, r *http.Request, method string) [ } envs = append(envs, fmt.Sprintf("Http_Method=%s", method)) - // DEPRECATED: Http_ContentLength will be deprecated in favour + // Deprecation notice: Http_ContentLength will be deprecated envs = append(envs, fmt.Sprintf("Http_ContentLength=%d", r.ContentLength)) envs = append(envs, fmt.Sprintf("Http_Content_Length=%d", r.ContentLength)) diff --git a/watchdog/requesthandler_test.go b/watchdog/requesthandler_test.go index 3f3eceba..6285cd67 100644 --- a/watchdog/requesthandler_test.go +++ b/watchdog/requesthandler_test.go @@ -55,6 +55,9 @@ func TestHandler_HasCustomHeaderInFunction_WithCgi_Mode(t *testing.T) { if !strings.Contains(val, "Http_ContentLength=0") { t.Errorf(config.faasProcess+" should print: Http_ContentLength=0, got: %s\n", val) } + if !strings.Contains(val, "Http_Content_Length=0") { + t.Errorf(config.faasProcess+" should print: Http_Content_Length=0, got: %s\n", val) + } if !strings.Contains(val, "Http_Custom_Header") { t.Errorf(config.faasProcess+" should print: Http_Custom_Header, got: %s\n", val) } @@ -94,6 +97,9 @@ func TestHandler_HasCustomHeaderInFunction_WithCgiMode_AndBody(t *testing.T) { if !strings.Contains(val, fmt.Sprintf("Http_ContentLength=%d", len(body))) { t.Errorf("'env' should printed: Http_ContentLength=0, got: %s\n", val) } + if !strings.Contains(val, fmt.Sprintf("Http_Content_Length=%d", len(body))) { + t.Errorf("'env' should printed: Http_Content_Length=0, got: %s\n", val) + } if !strings.Contains(val, "Http_Custom_Header") { t.Errorf("'env' should printed: Http_Custom_Header, got: %s\n", val) }