MCPcopy Create free account
hub / github.com/FastLED/FastLED / test_get_endpoint

Function test_get_endpoint

examples/Asio/ClientValidation/ClientValidationReal.h:124–167  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

122}
123
124void test_get_endpoint() {
125 FL_WARN("\n=== Test 2: GET /get (Request Echo) ===");
126
127 fl::task::Promise<fl::net::http::Response> promise = fl::net::http::fetch_get("http://localhost:8081/get");
128 fl::task::PromiseResult<fl::net::http::Response> result = fl::task::await_top_level(promise);
129
130 if (!result.ok()) {
131 FL_WARN("✗ FAILED: " << result.error_message());
132 tests_failed++;
133 state = FAILED;
134 return;
135 }
136
137 const fl::net::http::Response& resp = result.value();
138 if (resp.status() != 200) {
139 FL_WARN("✗ FAILED: Status " << resp.status() << " " << resp.status_text());
140 tests_failed++;
141 state = FAILED;
142 return;
143 }
144
145 if (!resp.is_json()) {
146 FL_WARN("✗ FAILED: Response is not JSON");
147 tests_failed++;
148 state = FAILED;
149 return;
150 }
151
152 fl::json data = resp.json();
153 fl::string origin = data["origin"] | fl::string("unknown");
154 fl::string url = data["url"] | fl::string("unknown");
155
156 if (origin == "unknown" || url == "unknown") {
157 FL_WARN("✗ FAILED: Invalid response structure");
158 tests_failed++;
159 state = FAILED;
160 return;
161 }
162
163 FL_WARN("✓ PASSED");
164 FL_WARN(" Origin: " << origin);
165 FL_WARN(" URL: " << url);
166 tests_passed++;
167}
168
169void test_ping_endpoint() {
170 FL_WARN("\n=== Test 3: GET /ping (Health Check) ===");

Callers 1

loopFunction · 0.85

Calls 9

fetch_getFunction · 0.85
await_top_levelFunction · 0.85
statusMethod · 0.80
is_jsonMethod · 0.80
stringClass · 0.50
okMethod · 0.45
error_messageMethod · 0.45
valueMethod · 0.45
jsonMethod · 0.45

Tested by

no test coverage detected