add tests#11
Conversation
| -- So you have to ignore them | ||
| -- {{ | ||
| package.preload['curl.driver'] = '../curl/driver.so' | ||
| -- package.preload['curl.driver'] = '../curl/driver.so' |
There was a problem hiding this comment.
It will not work on local environment. For instance, If user has builded curl.driver locally and he has not installed curl.driver into OS.
| @@ -13,33 +13,39 @@ http = curl.http() | |||
| local headers = { my_header = "1", my_header2 = "2" } | |||
| -- So you have to ignore them | ||
| -- {{ | ||
| package.preload['curl.driver'] = 'curl/driver.so' | ||
| -- package.preload['curl.driver'] = 'curl/driver.so' |
| host_good = 'https://httpbin.org/get' | ||
| host_bad = 'https://httpbin.org/not_get' | ||
|
|
||
| --function valid_response_get(value) |
|
|
||
|
|
||
| post_requests = {} | ||
| post_requests["sync_post_request"] = {f = http.sync_post_request, param = nil, host = "https://httpbin.org/post"} |
There was a problem hiding this comment.
A line length shouldn't be more than 80 symbols
| http = curl.http() | ||
|
|
||
| --{{ | ||
| -- Testing sync get calls |
There was a problem hiding this comment.
sync_funcs does not called by this program
| end | ||
| end | ||
|
|
||
| async_funcs = {} |
|
|
||
| function run(desc, func, param) | ||
| print('Running', desc) | ||
| ok, err = func(param) |
There was a problem hiding this comment.
run does not validate result. For instance, user did POST a data and that data has been corrupted by curl.driver (bug and so on).
Well, a good solution is validate a server's output body (echo server) and a client's input only if user's request has a body.
| } | ||
| } | ||
| else if (strcmp(method, "PUT") == 0) { | ||
| else if (strcmp(method, "PUT") == 0) { |
| lua_pop(L, 1); | ||
|
|
||
| /* Write callback */ | ||
| /* Write callback */ |
| return true, _ | ||
| end | ||
|
|
||
| --for key, value in pairs(sync_funcs) |
| return ctx.ok, ctx.msg | ||
| end | ||
|
|
||
| --for key, value in pairs(async_funcs) |
| return true | ||
| end | ||
|
|
||
| --for key, value in pairs(post_requests) |
| -- failed (included systeme erros, curl errors, HTTP | ||
| -- erros and so on) | ||
| -- failed (included system erros, curl errors, and so on | ||
| -- but not HTTP errors) |
There was a problem hiding this comment.
Corrected version is - ... and so on. But the counter does not include HTTP errors.
| } | ||
|
|
||
|
|
||
| value_header = "json/application" |
|
Any progress? |
No description provided.