Remove external calls from test fixtures#232
Conversation
Greptile SummaryThis PR replaces external
Confidence Score: 4/5Safe to merge; the change is narrowly scoped to test fixtures and all runtime assertions remain intact. The change is straightforward and well-executed across all runtimes. The only inconsistency is in the C++ fixture where tests/resources/functions/cpp/index.cc — the only file missing a default Important Files Changed
Reviews (1): Last reviewed commit: "fix: remove external calls from test fix..." | Re-trigger Greptile |
| std::string id = payload["id"].asString(); | ||
|
|
||
| Json::CharReaderBuilder builder; | ||
| Json::CharReader *reader = builder.newCharReader(); | ||
|
|
||
| CURL *curl; | ||
| CURLcode curlRes; | ||
| std::string todoBuffer; | ||
|
|
||
| curl = curl_easy_init(); | ||
| if (curl) | ||
| { | ||
| std::string url = "https://dummyjson.com/todos/" + id; | ||
| curl_easy_setopt(curl, CURLOPT_URL, url.c_str()); | ||
| curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, WriteCallback); | ||
| curl_easy_setopt(curl, CURLOPT_WRITEDATA, &todoBuffer); | ||
| curlRes = curl_easy_perform(curl); | ||
| curl_easy_cleanup(curl); | ||
| } | ||
|
|
||
| Json::Value todo; | ||
| reader->parse( | ||
| todoBuffer.c_str(), | ||
| todoBuffer.c_str() + todoBuffer.size(), | ||
| &todo, | ||
| nullptr | ||
| ); | ||
|
|
||
| delete reader; | ||
| todo["id"] = stoi(id); |
There was a problem hiding this comment.
Missing default for
id before stoi call
Every other runtime in this PR guards against a missing id in the request body (e.g. Node uses ?? 1, PHP uses ?? 1, .NET defaults to "1", Ruby uses || '1'). The C++ fixture does not: if payload["id"] is absent, asString() returns "" and stoi("") throws std::invalid_argument, crashing the function. The test currently always sends id = "2" so tests still pass, but the fixture diverges from the defensive pattern used in every other language.
What changed
Why
Executor E2E tests should not depend on external network availability. The fixture response shape is unchanged for assertions, including
todo.userId = 13.Testing
composer formatphp -l tests/resources/functions/php/index.phpnode --check tests/resources/functions/node/index.jspython3 -m py_compile tests/resources/functions/python/index.py