FastLED 3.9.15
Loading...
Searching...
No Matches

◆ test_ping_endpoint()

void test_ping_endpoint ( )

Definition at line 169 of file ClientValidationReal.h.

169 {
170 FL_WARN("\n=== Test 3: GET /ping (Health Check) ===");
171
172 fl::task::Promise<fl::net::http::Response> promise = fl::net::http::fetch_get("http://localhost:8081/ping");
174
175 if (!result.ok()) {
176 FL_WARN("✗ FAILED: " << result.error_message());
177 tests_failed++;
178 state = FAILED;
179 return;
180 }
181
182 const fl::net::http::Response& resp = result.value();
183 if (resp.status() != 200) {
184 FL_WARN("✗ FAILED: Status " << resp.status() << " " << resp.status_text());
185 tests_failed++;
186 state = FAILED;
187 return;
188 }
189
190 fl::string body = resp.text();
191 if (body != "pong\n") {
192 FL_WARN("✗ FAILED: Expected 'pong\\n', got '" << body << "'");
193 tests_failed++;
194 state = FAILED;
195 return;
196 }
197
198 FL_WARN("✓ PASSED");
199 FL_WARN(" Response: " << body.substr(0, body.length() - 1)); // Strip newline for display
200 tests_passed++;
201}
int tests_passed
int tests_failed
TestState state
fl::size length() const FL_NOEXCEPT
const fl::string & text() const
Response body as text (like JavaScript response.text())
Definition fetch.h:95
const fl::string & status_text() const
HTTP status text (like JavaScript response.statusText)
Definition fetch.h:89
int status() const
HTTP status code (like JavaScript response.status)
Definition fetch.h:86
HTTP response class (unified interface)
Definition fetch.h:78
string substr(fl::size start, fl::size length) const FL_NOEXCEPT
Promise class that provides fluent .then() and .catch_() semantics This is a lightweight wrapper arou...
Definition promise.h:58
Result type for promise operations.
#define FL_WARN(X)
Definition log.h:276
fl::task::Promise< Response > fetch_get(const fl::string &url, const FetchOptions &request)
HTTP GET request.
PromiseResult< T > await_top_level(Promise< T > p)
Synchronously wait for a promise to complete (ONLY safe in top-level contexts)
Definition executor.h:186
expected< T, E > result
Alias for expected (Rust-style naming)
Definition result.h:31

References fl::task::await_top_level(), FAILED, fl::net::http::fetch_get(), FL_WARN, fl::basic_string::length(), state, fl::net::http::Response::status(), fl::net::http::Response::status_text(), fl::string::substr(), tests_failed, tests_passed, and fl::net::http::Response::text().

Referenced by loop().

+ Here is the call graph for this function:
+ Here is the caller graph for this function: