mirror of
https://github.com/fnproject/fn.git
synced 2022-10-28 21:29:17 +03:00
fn: json excess data check should ignore whitespace (#830)
* fn: json excess data check should ignore whitespace * fn: adjustments and test case
This commit is contained in:
@@ -186,6 +186,7 @@ func TestRouteRunnerIOPipes(t *testing.T) {
|
||||
|
||||
// sleep between logs and with debug enabled, fn-test-utils will log header/footer below:
|
||||
immediateGarbage := `{"isDebug": true, "postOutGarbage": "YOGURT_YOGURT_YOGURT", "postSleepTime": 0}`
|
||||
immediateJsonValidGarbage := `{"isDebug": true, "postOutGarbage": "\r", "postSleepTime": 0}`
|
||||
delayedGarbage := `{"isDebug": true, "postOutGarbage": "YOGURT_YOGURT_YOGURT", "postSleepTime": 1000}`
|
||||
ok := `{"isDebug": true}`
|
||||
|
||||
@@ -203,6 +204,9 @@ func TestRouteRunnerIOPipes(t *testing.T) {
|
||||
//
|
||||
// JSON WORLD
|
||||
//
|
||||
// this should go through.
|
||||
{"/r/zoo/json/", immediateJsonValidGarbage, "GET", http.StatusOK, "", nil, 0},
|
||||
|
||||
// CASE I: immediate garbage: likely to be in the json decoder buffer after json resp parsing
|
||||
{"/r/zoo/json/", immediateGarbage, "GET", http.StatusOK, "", nil, 0},
|
||||
|
||||
@@ -275,20 +279,22 @@ func TestRouteRunnerIOPipes(t *testing.T) {
|
||||
t.Logf("Test %d: dockerId: %v", i, containerIds[i])
|
||||
time.Sleep(test.sleepAmount)
|
||||
}
|
||||
jsonIds := containerIds[0:4]
|
||||
|
||||
jsonIds := containerIds[0:5]
|
||||
|
||||
// now cross check JSON container ids:
|
||||
if jsonIds[0] != jsonIds[1] &&
|
||||
jsonIds[2] == "N/A" &&
|
||||
jsonIds[1] != jsonIds[2] &&
|
||||
jsonIds[2] != jsonIds[3] {
|
||||
if jsonIds[1] != jsonIds[2] &&
|
||||
jsonIds[0] == jsonIds[1] &&
|
||||
jsonIds[3] == "N/A" &&
|
||||
jsonIds[2] != jsonIds[3] &&
|
||||
jsonIds[3] != jsonIds[4] {
|
||||
t.Logf("json container ids are OK, ids=%v", jsonIds)
|
||||
} else {
|
||||
isFailure = true
|
||||
t.Errorf("json container ids are not OK, ids=%v", jsonIds)
|
||||
}
|
||||
|
||||
httpids := containerIds[4:]
|
||||
httpids := containerIds[5:]
|
||||
|
||||
// now cross check HTTP container ids:
|
||||
if httpids[0] == httpids[1] &&
|
||||
|
||||
Reference in New Issue
Block a user