| 167 | } |
| 168 | |
| 169 | void test_ping_endpoint() { |
| 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"); |
| 173 | fl::task::PromiseResult<fl::net::http::Response> result = fl::task::await_top_level(promise); |
| 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 | } |
| 202 | |
| 203 | void setup() { |
| 204 | Serial.begin(115200); |
no test coverage detected