feat: 实现RCU固件升级服务核心功能
- 添加升级服务主逻辑,包括定时触发升级、状态查询和日志记录 - 实现数据库初始化脚本和日志表结构 - 添加PM2部署配置文件 - 实现环境变量配置系统 - 添加API客户端模块处理外部接口调用 - 实现升级状态轮询和超时处理机制 - 添加测试用例验证核心功能
This commit is contained in:
9
tests/apiClient.test.js
Normal file
9
tests/apiClient.test.js
Normal file
@@ -0,0 +1,9 @@
|
||||
const apiClient = require('../src/apiClient');
|
||||
|
||||
describe('API Client', () => {
|
||||
test('should be defined', () => {
|
||||
expect(apiClient).toBeDefined();
|
||||
expect(apiClient.triggerUpgrade).toBeDefined();
|
||||
expect(apiClient.queryStatus).toBeDefined();
|
||||
});
|
||||
});
|
||||
17
tests/config.test.js
Normal file
17
tests/config.test.js
Normal file
@@ -0,0 +1,17 @@
|
||||
const config = require('../src/config');
|
||||
|
||||
describe('Config Loader', () => {
|
||||
test('should load and parse UPGRADE_CONFIG correctly', () => {
|
||||
expect(Array.isArray(config.upgradeConfig)).toBe(true);
|
||||
const group = config.upgradeConfig[0];
|
||||
expect(Array.isArray(group.hosts)).toBe(true);
|
||||
expect(Array.isArray(group.roomtypes)).toBe(true);
|
||||
expect(group.roomtypes.length).toBe(2);
|
||||
expect(group.roomtypes[0]).toHaveProperty('roomtype_id');
|
||||
expect(group.roomtypes[0]).toHaveProperty('fileName');
|
||||
});
|
||||
|
||||
test('should have default cron schedule', () => {
|
||||
expect(config.cronSchedule).toBeDefined();
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user