Skip to content
Snippets Groups Projects
Commit 30cf8de8 authored by Alex Ellis (VMware)'s avatar Alex Ellis (VMware)
Browse files

Update combine_output test


Integration test for combine_output should use stat instead of
man as man is not installed in the CI system.

Signed-off-by: default avatarAlex Ellis (VMware) <alexellis2@gmail.com>
parent 3031d0e1
No related branches found
No related tags found
No related merge requests found
...@@ -117,7 +117,7 @@ func TestHandler_StderrWritesToStderr_CombinedOutput_False(t *testing.T) { ...@@ -117,7 +117,7 @@ func TestHandler_StderrWritesToStderr_CombinedOutput_False(t *testing.T) {
} }
config := WatchdogConfig{ config := WatchdogConfig{
faasProcess: "man badtopic", faasProcess: "stat x",
cgiHeaders: true, cgiHeaders: true,
combineOutput: false, combineOutput: false,
} }
...@@ -137,8 +137,9 @@ func TestHandler_StderrWritesToStderr_CombinedOutput_False(t *testing.T) { ...@@ -137,8 +137,9 @@ func TestHandler_StderrWritesToStderr_CombinedOutput_False(t *testing.T) {
stderrBytes, _ := ioutil.ReadAll(b) stderrBytes, _ := ioutil.ReadAll(b)
stderrVal := string(stderrBytes) stderrVal := string(stderrBytes)
if strings.Contains(stderrVal, "No manual entry for") == false { want := "No such file or directory"
t.Logf("Stderr should have contained error from function \"No manual entry for\", but was: %s", stderrVal) if strings.Contains(stderrVal, want) == false {
t.Logf("Stderr should have contained error from function \"%s\", but was: %s", want, stderrVal)
t.Fail() t.Fail()
} }
} }
...@@ -157,7 +158,7 @@ func TestHandler_StderrWritesToResponse_CombinedOutput_True(t *testing.T) { ...@@ -157,7 +158,7 @@ func TestHandler_StderrWritesToResponse_CombinedOutput_True(t *testing.T) {
} }
config := WatchdogConfig{ config := WatchdogConfig{
faasProcess: "man badtopic", faasProcess: "stat x",
cgiHeaders: true, cgiHeaders: true,
combineOutput: true, combineOutput: true,
} }
...@@ -176,21 +177,23 @@ func TestHandler_StderrWritesToResponse_CombinedOutput_True(t *testing.T) { ...@@ -176,21 +177,23 @@ func TestHandler_StderrWritesToResponse_CombinedOutput_True(t *testing.T) {
stderrBytes, _ := ioutil.ReadAll(b) stderrBytes, _ := ioutil.ReadAll(b)
stderrVal := string(stderrBytes) stderrVal := string(stderrBytes)
stdErrWant := "No such file or directory"
if strings.Contains(stderrVal, "No manual entry for") { if strings.Contains(stderrVal, stdErrWant) {
t.Logf("stderr should have not included any function errors, but did") t.Logf("stderr should have not included any function errors, but did")
t.Fail() t.Fail()
} }
bodyBytes, _ := ioutil.ReadAll(rr.Body) bodyBytes, _ := ioutil.ReadAll(rr.Body)
bodyStr := string(bodyBytes) bodyStr := string(bodyBytes)
want := `exit status 1 stdOuputWant := `exit status 1`
No manual entry for badtopic` if strings.Contains(bodyStr, stdOuputWant) == false {
if strings.Contains(bodyStr, want) == false { t.Logf("response want: %s, got: %s", stdOuputWant, bodyStr)
t.Logf("response want: %s, got: %s", want, bodyStr) t.Fail()
}
if strings.Contains(bodyStr, stdErrWant) == false {
t.Logf("response want: %s, got: %s", stdErrWant, bodyStr)
t.Fail() t.Fail()
} }
} }
func TestHandler_DoesntHaveCustomHeaderInFunction_WithoutCgi_Mode(t *testing.T) { func TestHandler_DoesntHaveCustomHeaderInFunction_WithoutCgi_Mode(t *testing.T) {
......
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