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

◆ runTest()

void LoopbackTestRunner::runTest ( const char * name,
const char * url,
const char * expected,
TestSequenceState next_state )
inlineprivate

Definition at line 122 of file LoopbackTestRunner.h.

123 {
124 FL_WARN("[LOOPBACK] Running test: " << name << " -> " << url);
125 Serial.print("Running test: ");
126 Serial.println(name);
127
128 tests_run++;
129
130 // Launch async HTTP request with non-blocking .then()/.catch_() callbacks
132 .then([this, expected, next_state](const fl::net::http::Response& resp) {
133 // Success callback - validate response
134 if (resp.status() == 200 && resp.text() == expected) {
135 tests_passed++;
136 Serial.println(" ✓ PASSED");
137 } else {
138 has_failure = true;
139 Serial.print(" ✗ FAILED - ");
140 if (resp.status() != 200) {
141 Serial.print("Status: ");
142 Serial.print(static_cast<int>(resp.status()));
143 } else {
144 Serial.print("Expected: '");
145 Serial.print(expected);
146 Serial.print("', Got: '");
147 Serial.print(resp.text().c_str());
148 Serial.print("'");
149 }
150 Serial.println();
151 }
152
153 // Advance to next test state
154 state = next_state;
155 })
156 .catch_([this](const fl::task::Error& err) {
157 // Error callback - network/connection failure
158 has_failure = true;
159 Serial.print(" ✗ FAILED - Error: ");
160 Serial.println(err.message.c_str());
161
162 // Abort remaining tests on network error
164 });
165
166 // Immediately transition to waiting state (non-blocking)
167 state = static_cast<TestSequenceState>(state + 1); // RUNNING_X -> WAITING_X
168 }
TestSequenceState state
const char * c_str() const FL_NOEXCEPT
const fl::string & text() const
Response body as text (like JavaScript response.text())
Definition fetch.h:95
int status() const
HTTP status code (like JavaScript response.status)
Definition fetch.h:86
#define FL_WARN(X)
Definition log.h:276
fl::task::Promise< Response > fetch_get(const fl::string &url, const FetchOptions &request)
HTTP GET request.
fl::string message
Definition promise.h:40
#define Serial
Definition serial.h:304

References fl::basic_string::c_str(), COMPLETED, fl::net::http::fetch_get(), FL_WARN, has_failure, fl::task::Error::message, Serial, state, fl::net::http::Response::status(), tests_passed, tests_run, and fl::net::http::Response::text().

Referenced by update().

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