Resolve JSON.CONTENT with JSON object or JSON array
authorjapps opened this issue · 10 comments
Background
Currently the following are supported and resolved i.e. JSON.FILE
i.e. ${JSON.FILE:path/to/actual/json/content.json}"
gets resolved during runtime.
{
"scenarioName": "POST via file body - reuse payload",
"steps": [
{
"name": "create_emp",
"url": "/home/api/employee",
"operation": "POST",
"request": {
"body" : "${JSON.FILE:integration_test_files/filebody/bodyonly/request_body.json}"
},
"assertions": {
"status": 201
}
}
]
}
AC1:
Simillar way:
Support and resolve JSON.CONTENT
(this time not from a file but from this scenario step(s))
i.e.
${JSON.CONTENT:<json_path_to_a_json_object_or_array in this scenario file>}
gets resolved during runtime.
where example of,
json object :
{
"foo": "bar"
}
json array :
[
{
"foo1": "bar1"
},
{
"foo2": "bar2"
}
]
and also,
[1,2,3]
or
["string1", "string2"]
etc
Example Usecase Scenario
{
"scenarioName": "GET Employee Office Address",
"steps": [
{
"name": "get_emp",
"url": "/home/api/employee/EMP101",
"operation": "GET",
"request": {
"headers":{
"x-req-token": "11-22-3abe"
}
},
"assertions": {
"status": 200,
"body":{
"employee":{
"id":"EMP101",
"type":"CONTRACT",
"address":{
"type":"office",
"line1":"99 London Newton St",
"postcode":"LON3 9XR"
}
}
}
}
},
{
"name": "create_new_emp",
"url": "/home/api/employee",
"operation": "GET",
"request": {
"headers":{
"x-req-token": "33-44-3abe"
},
"body" : {
"fullName":"Bob Luis",
"empLogin":"bolu_lon",
"type":"CONTRACT",
"address":"${JSON.CONTENT:$.get_emp.response.body.employee.address}"
}
},
"assertions": {
"status": 201,
"body":{
"employee":{
"id":"EMP102", // <--- New employee with a new ID
"type":"CONTRACT",
"address":{ // <--- Same office address as of earlier employee
"type":"office",
"line1":"99 London Newton St",
"postcode":"LON3 9XR"
}
}
}
}
}
]
}
Suggestion:
Try to reuse the code implemented for JSON.FILE
for ser-de logic.
Can you assign me this task
Can you assign me this task
Done.
Thanks for picking this.
Can you please share or link the PR here or to this issue when you're ready?
ETA:
Around 2 weeks. 20th Nov 2023.
Hi there.
Is this issue still available? I would like to work on it.
Can you assign me this task
Hello @kpidiba, Hope you're well. It seems like there is not lot going on wrt the PR we are aiming by 20th Nov.
Forked repo: https://github.com/kpidiba/zerocode
It could be you are busy with your day job or so which is not a problem.
So could you please unassign to yourself and assign to @furkannzmnn to get this issue fixed?
Thanks for understanding!
Can you assign me this task
Thanks for your interest!
Now you can proceed please @furkannzmnn.
Do you have an ETA for this?
Hi @authorjapps would you please assign this issue to me if it is available.
Hi @authorjapps would you please assign this issue to me if it is available.
Done @vivektiwary , thanks for your interest.
Do you have an ETA for this?
PR #612 has been merged.
This feature is available in 1.3.36
(and higher releases) once released.
Documentation is et to be created/updated for this.
Visit here and update/contribute to the Doc for this: https://zerocode-tdd-docs.pages.dev (and raise a PR once done)