mirror of
https://github.com/emsesp/EMS-ESP32.git
synced 2025-12-06 07:49:52 +03:00
added full tests for different version upgrades, both backend and webUI
This commit is contained in:
@@ -112,41 +112,46 @@ let system_status = {
|
||||
status: 3
|
||||
};
|
||||
|
||||
let VERSION_IS_UPGRADEABLE: boolean;
|
||||
// Testing Versioning
|
||||
let DEV_VERSION_IS_UPGRADEABLE: boolean;
|
||||
let STABLE_VERSION_IS_UPGRADEABLE: boolean;
|
||||
let THIS_VERSION: string;
|
||||
let version_test: number;
|
||||
|
||||
// Versions
|
||||
// default - on latest stable, no stable upgrades
|
||||
let THIS_VERSION = '3.7.2';
|
||||
let LATEST_STABLE_VERSION = '3.7.2';
|
||||
let LATEST_DEV_VERSION = '3.7.3-dev.3';
|
||||
|
||||
// scenarios for testing versioning
|
||||
let version_test = 0;
|
||||
version_test = 0; // on latest stable, no upgrades, but can switch
|
||||
// version_test = 1; // on latest dev, no update
|
||||
// version_test = 2; // on stable, upgrade stable to latest stable
|
||||
// version_test = 3; // on dev, upgrade dev to latest dev
|
||||
version_test = 0; // on latest stable, can upgrade to dev only
|
||||
// version_test = 1; // on latest dev, no updates to either dev or stable
|
||||
// version_test = 2; // upgrade an older stable to latest stable or the latest dev
|
||||
// version_test = 3; // upgrade an older dev to latest dev, no stable upgrades available
|
||||
|
||||
switch (version_test as number) {
|
||||
case 0:
|
||||
default:
|
||||
// use default - on latest stable, no upgrades, but can switch
|
||||
VERSION_IS_UPGRADEABLE = false;
|
||||
// on latest stable, can upgrade to dev only
|
||||
THIS_VERSION = LATEST_STABLE_VERSION;
|
||||
STABLE_VERSION_IS_UPGRADEABLE = false;
|
||||
DEV_VERSION_IS_UPGRADEABLE = true;
|
||||
break;
|
||||
case 1:
|
||||
// on latest dev, no update
|
||||
// on latest dev, no updates to either dev or stable
|
||||
THIS_VERSION = LATEST_DEV_VERSION;
|
||||
VERSION_IS_UPGRADEABLE = false;
|
||||
STABLE_VERSION_IS_UPGRADEABLE = false;
|
||||
DEV_VERSION_IS_UPGRADEABLE = false;
|
||||
break;
|
||||
case 2:
|
||||
// upgrade stable to latest stable
|
||||
// upgrade an older stable to latest stable or the latest dev
|
||||
THIS_VERSION = '3.6.5';
|
||||
VERSION_IS_UPGRADEABLE = true;
|
||||
STABLE_VERSION_IS_UPGRADEABLE = true;
|
||||
DEV_VERSION_IS_UPGRADEABLE = true;
|
||||
break;
|
||||
case 3:
|
||||
// upgrade dev to latest dev
|
||||
THIS_VERSION = '3.7.3-dev-1';
|
||||
VERSION_IS_UPGRADEABLE = true;
|
||||
// upgrade an older dev to latest dev, no stable upgrades available
|
||||
THIS_VERSION = '3.7.3-dev.2';
|
||||
STABLE_VERSION_IS_UPGRADEABLE = false;
|
||||
DEV_VERSION_IS_UPGRADEABLE = true;
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -360,21 +365,23 @@ function check_upgrade(version: string) {
|
||||
if (version) {
|
||||
const dev_version = version.split(',')[0];
|
||||
const stable_version = version.split(',')[1];
|
||||
|
||||
console.log(
|
||||
'latest dev version: ' +
|
||||
dev_version +
|
||||
', latest stable version: ' +
|
||||
stable_version
|
||||
);
|
||||
console.log(
|
||||
'Version upgrade check from version ' +
|
||||
'Version upgrade check from this version (' +
|
||||
THIS_VERSION +
|
||||
', upgradable: ' +
|
||||
VERSION_IS_UPGRADEABLE
|
||||
') to dev (' +
|
||||
dev_version +
|
||||
') is ' +
|
||||
(DEV_VERSION_IS_UPGRADEABLE ? 'YES' : 'NO') +
|
||||
' and to stable (' +
|
||||
stable_version +
|
||||
') is ' +
|
||||
(STABLE_VERSION_IS_UPGRADEABLE ? 'YES' : 'NO')
|
||||
);
|
||||
data = {
|
||||
emsesp_version: THIS_VERSION,
|
||||
upgradeable: VERSION_IS_UPGRADEABLE
|
||||
dev_upgradeable: DEV_VERSION_IS_UPGRADEABLE,
|
||||
stable_upgradeable: STABLE_VERSION_IS_UPGRADEABLE
|
||||
};
|
||||
} else {
|
||||
console.log('requesting ems-esp version (' + THIS_VERSION + ')');
|
||||
|
||||
@@ -1112,19 +1112,30 @@ void Test::run_test(uuid::console::Shell & shell, const std::string & cmd, const
|
||||
// EMSESP::webStatusService.action(&request, doc.as<JsonVariant>());
|
||||
|
||||
// test version checks
|
||||
// test with "current_version_s = "3.7.1-dev.8" in WebStatusService::checkUpgrade()
|
||||
// request.url("/rest/action");
|
||||
// deserializeJson(doc, "{\"action\":\"checkUpgrade\", \"param\":\"3.7.1-dev.9,3.7.0\"}"); // is upgradable
|
||||
// EMSESP::webStatusService.action(&request, doc.as<JsonVariant>());
|
||||
// deserializeJson(doc, "{\"action\":\"checkUpgrade\", \"param\":\"3.7.1-dev.7,3.7.0\"}"); // is not upgradable
|
||||
// EMSESP::webStatusService.action(&request, doc.as<JsonVariant>());
|
||||
// use same data as in rest_server.ts
|
||||
// log shows first if you can upgrade to dev, and then if you can upgrade to stable
|
||||
request.url("/rest/action");
|
||||
std::string LATEST_STABLE_VERSION = "3.7.2";
|
||||
std::string LATEST_DEV_VERSION = "3.7.3-dev.3";
|
||||
std::string param = LATEST_DEV_VERSION + "," + LATEST_STABLE_VERSION;
|
||||
std::string action = "{\"action\":\"checkUpgrade\", \"param\":\"" + param + "\"}";
|
||||
deserializeJson(doc, action);
|
||||
|
||||
// test with "current_version_s = "3.6.5" in WebStatusService::checkUpgrade()
|
||||
// request.url("/rest/action");
|
||||
// deserializeJson(doc, "{\"action\":\"checkUpgrade\", \"param\":\"3.7.1-dev.9,3.6.5\"}"); // is noy upgradable
|
||||
// EMSESP::webStatusService.action(&request, doc.as<JsonVariant>());
|
||||
// deserializeJson(doc, "{\"action\":\"checkUpgrade\", \"param\":\"3.7.1-dev.7,3.7.0\"}"); // is upgradable
|
||||
// EMSESP::webStatusService.action(&request, doc.as<JsonVariant>());
|
||||
// case 0: on latest stable, can upgrade to dev only. So true, false
|
||||
EMSESP::webStatusService.set_current_version(LATEST_STABLE_VERSION);
|
||||
EMSESP::webStatusService.action(&request, doc.as<JsonVariant>());
|
||||
|
||||
// case 1: on latest dev, no updates to either dev or stable. So false, false
|
||||
EMSESP::webStatusService.set_current_version(LATEST_DEV_VERSION);
|
||||
EMSESP::webStatusService.action(&request, doc.as<JsonVariant>());
|
||||
|
||||
// case 2: upgrade an older stable to latest stable or the latest dev. So true, true
|
||||
EMSESP::webStatusService.set_current_version("3.6.5");
|
||||
EMSESP::webStatusService.action(&request, doc.as<JsonVariant>());
|
||||
|
||||
// case 3: upgrade an older dev to latest dev, no stable upgrades available. So true, false
|
||||
EMSESP::webStatusService.set_current_version("3.7.3-dev.2");
|
||||
EMSESP::webStatusService.action(&request, doc.as<JsonVariant>());
|
||||
|
||||
// char data6[] = "{\"device\":\"system\", \"cmd\":\"read\",\"value\":\"8 2 27 1\"}";
|
||||
// deserializeJson(doc, data6);
|
||||
|
||||
@@ -41,7 +41,7 @@ namespace emsesp {
|
||||
// #define EMSESP_DEBUG_DEFAULT "310"
|
||||
// #define EMSESP_DEBUG_DEFAULT "render"
|
||||
// #define EMSESP_DEBUG_DEFAULT "api"
|
||||
// #define EMSESP_DEBUG_DEFAULT "api3"
|
||||
#define EMSESP_DEBUG_DEFAULT "api3"
|
||||
// #define EMSESP_DEBUG_DEFAULT "api4"
|
||||
// #define EMSESP_DEBUG_DEFAULT "crash"
|
||||
// #define EMSESP_DEBUG_DEFAULT "dv"
|
||||
|
||||
Reference in New Issue
Block a user