Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
martinrode committed Dec 9, 2020
2 parents 99783d4 + 826a8dc commit 3503f82
Show file tree
Hide file tree
Showing 6 changed files with 85 additions and 8 deletions.
17 changes: 9 additions & 8 deletions api_testcase.go
Original file line number Diff line number Diff line change
Expand Up @@ -255,14 +255,15 @@ func (testCase Case) executeRequest(counter int) (compare.CompareResult, api.Req
}
apiResp.Format = expectedResponse.Format

if testCase.ResponseData != nil || testCase.CollectResponse != nil ||
len(testCase.BreakResponse) > 0 || len(testCase.StoreResponse) > 0 {
apiRespJsonString, err = apiResp.ServerResponseToJsonString(false)
if err != nil {
testCase.LogReq(req)
err = fmt.Errorf("error getting json from response: %s", err)
return responsesMatch, req, apiResp, err
}
apiRespJsonString, err = apiResp.ServerResponseToJsonString(false)
// If we don't define an expected response, we won't have a format
// That's problematic if the response is not JSON, as we try to parse it for the datastore anyway
// So we don't fail the test in that edge case
if err != nil && (testCase.ResponseData != nil || testCase.CollectResponse != nil ||
len(testCase.BreakResponse) > 0 || len(testCase.StoreResponse) > 0) {
testCase.LogReq(req)
err = fmt.Errorf("error getting json from response: %s", err)
return responsesMatch, req, apiResp, err
}

// Store in custom store
Expand Down
29 changes: 29 additions & 0 deletions test/datastore/check.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
[
{
"name": "check datastore values by bouncing them",
"request": {
"server_url": "http://localhost:9999",
"endpoint": "bounce-json",
"method": "POST",
"body": [
{{ datastore -3 | qjson "body" }},
{{ datastore -2 | qjson "body" }},
{{ datastore -1 | qjson "body" }}
]
},
"response": {
"statuscode": 200,
"body": {
"body": [
{"some": "data"},
{"some": ["more", "data"]},
{"some": "data"}
],
"body:control": {
"order_matters": true,
"no_extra": true
}
}
}
}
]
3 changes: 3 additions & 0 deletions test/datastore/data1.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"some": "data"
}
3 changes: 3 additions & 0 deletions test/datastore/data2.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"some": ["more", "data"]
}
12 changes: 12 additions & 0 deletions test/datastore/manifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"http_server": {
"addr": ":9999",
"dir": "./",
"testmode": false
},
"name": "check datastore proper values",
"tests": [
"@requests.json",
"@check.json"
]
}
29 changes: 29 additions & 0 deletions test/datastore/requests.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
[
{
"name": "add data thru request - 1",
"request": {
"server_url": "http://localhost:9999",
"endpoint": "data1.json",
"method": "GET"
},
"response": {
"body": {"some": "data"}
}
},
{
"name": "add data thru request - 2",
"request": {
"server_url": "http://localhost:9999",
"endpoint": "data2.json",
"method": "GET"
}
},
{
"name": "add data thru request - 3",
"request": {
"server_url": "http://localhost:9999",
"endpoint": "data1.json",
"method": "GET"
}
}
]

0 comments on commit 3503f82

Please sign in to comment.