update unit tests

This commit is contained in:
proddy
2025-09-21 19:18:32 +02:00
parent f1c5a911f9
commit fbc11b8ef8
3 changed files with 240 additions and 96 deletions

View File

@@ -17,13 +17,12 @@
*/
#include <Arduino.h>
#include <unity.h>
#include <emsesp.h>
#include "ESPAsyncWebServer.h"
#include "web/WebAPIService.h"
#include "test_shuntingYard.hpp"
#include "test_shuntingYard.h"
using namespace emsesp;
@@ -280,6 +279,12 @@ void manual_test6() {
TEST_ASSERT_EQUAL_STRING(expected_response, call_url("/api/analogsensor/setvalue", data));
}
void manual_test7() {
auto expected_response = "[{}]"; // empty is good
char data[] = "{\"value\":9}";
TEST_ASSERT_EQUAL_STRING(expected_response, call_url("/api/custom/test_ram", data));
}
void run_manual_tests() {
RUN_TEST(manual_test1);
@@ -288,6 +293,7 @@ void run_manual_tests() {
RUN_TEST(manual_test4);
RUN_TEST(manual_test5);
RUN_TEST(manual_test6);
RUN_TEST(manual_test7);
}
const char * run_console_command(const char * command) {
@@ -362,14 +368,16 @@ void create_tests() {
// custom
capture("/api/custom");
capture("/api/custom/info");
capture("/api/custom/seltemp");
capture("/api/custom/test_seltemp");
capture("/api/custom/test_seltemp/value");
capture("/api/custom/test_custom");
// system
capture("/api/system");
capture("/api/system/info");
capture("/api/system/settings/locale");
capture("/api/system/fetch");
capture("api/system/network/values");
capture("/api/system/network/values");
// scheduler
capture("/api/scheduler");
@@ -389,7 +397,10 @@ void create_tests() {
capture("/api/analogsensor/test_analogsensor1");
capture("/api/analogsensor/test_analogsensor1/offset");
// these tests should all fail...
//
// these next tests should all fail...
//
capture("/api/boiler2");
capture("/api/boiler/bad/value");
capture("/api/boiler/comfort/valu");
@@ -405,8 +416,8 @@ void create_tests() {
capture("/api/scheduler/test_scheduler2/val2");
// custom
capture("/api/custom/seltemp2");
capture("/api/custom/seltemp/val");
capture("/api/custom/test_seltemp2");
capture("/api/custom/test_seltemp/val");
// temperaturesensor
capture("/api/temperaturesensor/test_sensor20");
@@ -437,15 +448,17 @@ int main() {
application.start(); // calls begin()
EMSESP::webCustomEntityService.test(); // custom entities
EMSESP::webCustomizationService.test(); // set customizations - this will overwrite any settings in the FS
EMSESP::temperaturesensor_.test(); // add temperature sensors
EMSESP::webSchedulerService.test(); // run scheduler tests, and conditions
// populate with data, like custom entities, fake temp sensors and scheduler items
EMSESP::webCustomEntityService.load_test_data(); // custom entities
EMSESP::webCustomizationService.load_test_data(); // set customizations - this will overwrite any settings in the FS
EMSESP::temperaturesensor_.load_test_data(); // add temperature sensors
EMSESP::webSchedulerService.load_test_data(); // run scheduler tests, and conditions
add_devices(); // add devices
#if defined(EMSESP_UNITY_CREATE)
create_tests();
return 0;
#endif
//