error handling improvements - Refactor MQTT subscriptions #173

This commit is contained in:
proddy
2021-11-02 13:59:36 +01:00
parent b76b6be3d1
commit 5850a82d80
8 changed files with 124 additions and 66 deletions

View File

@@ -498,6 +498,11 @@ void Test::run_test(uuid::console::Shell & shell, const std::string & cmd) {
/*
AsyncWebServerRequest request2;
request2.method(HTTP_GET);
request2.url("/api/thermostat/mode/auto"); // check if defaults to info
EMSESP::webAPIService.webAPIService_get(&request2);
return;
request2.url("/api/thermostat"); // check if defaults to info
EMSESP::webAPIService.webAPIService_get(&request2);
request2.url("/api/thermostat/info");
@@ -524,6 +529,18 @@ void Test::run_test(uuid::console::Shell & shell, const std::string & cmd) {
return;
*/
/*
AsyncWebServerRequest request3;
request3.method(HTTP_POST);
DynamicJsonDocument docX(2000);
JsonVariant jsonX;
char dataX[] = "{}";
deserializeJson(docX, dataX);
jsonX = docX.as<JsonVariant>();
request3.url("/api/thermostat/mode/auto"); // should fail
EMSESP::webAPIService.webAPIService_post(&request3, jsonX);
*/
// test command parse
int8_t id_n;
const char * cmd;
@@ -564,8 +581,9 @@ void Test::run_test(uuid::console::Shell & shell, const std::string & cmd) {
EMSESP::mqtt_.incoming("ems-esp/system/send", "11 12 13");
// MQTT bad tests
EMSESP::mqtt_.incoming("ems-esp/thermostate/mode", "auto"); // unknown device
EMSESP::mqtt_.incoming("ems-esp/thermostat/modee", "auto"); // unknown command
EMSESP::mqtt_.incoming("ems-esp/thermostate/mode", "auto"); // unknown device
EMSESP::mqtt_.incoming("ems-esp/thermostat/modee", "auto"); // unknown command
EMSESP::mqtt_.incoming("ems-esp/thermostat/mode/auto", "auto"); // invalid
// check long base
Mqtt::base("home/cellar/heating");
@@ -649,6 +667,13 @@ void Test::run_test(uuid::console::Shell & shell, const std::string & cmd) {
request.url("/rest/writeValue");
EMSESP::webDataService.write_value(&request, json);
// should fail
char data8[] = "{}";
deserializeJson(doc, data8);
json = doc.as<JsonVariant>();
request.url("/api/thermostat/mode/auto");
EMSESP::webAPIService.webAPIService_post(&request, json);
#endif
}