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: Alex Ellis (VMware) <alexellis2@gmail.com>
This commit is contained in:
Alex Ellis (VMware)
2018-03-17 21:12:44 +00:00
parent 3031d0e1c2
commit 30cf8de89b

View File

@ -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) {
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) {
} }
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) {
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) {