fix(pulse-openclaw): update gateway-health test mock for systemctl MainPID
PR #80 changed pgrep to systemctl show --property=MainPID + ps, but tests still mocked only one execSync call (the ps call). Now mock systemctl call first, then ps call. Ref #80 Co-authored-by: 小橘 <xiaoju@shazhou.work>
This commit is contained in:
@@ -37,6 +37,7 @@ describe('gatewayHealthWatcher', () => {
|
||||
});
|
||||
|
||||
mockExecSync
|
||||
.mockReturnValueOnce('12345\n') // systemctl → PID
|
||||
.mockReturnValueOnce('1048576\n') // ps → 1048576 KB = 1024 MB
|
||||
.mockReturnValueOnce('50\n'); // du
|
||||
mockFs.readdirSync.mockReturnValue([]);
|
||||
@@ -52,7 +53,7 @@ describe('gatewayHealthWatcher', () => {
|
||||
fsFn: mockFs as any,
|
||||
});
|
||||
|
||||
mockExecSync.mockReturnValueOnce(''); // no process
|
||||
mockExecSync.mockReturnValueOnce('0\n'); // systemctl → MainPID=0 (not running)
|
||||
mockFs.readdirSync.mockReturnValue([]);
|
||||
|
||||
const result = await watcher.collect();
|
||||
@@ -158,6 +159,7 @@ describe('gatewayHealthWatcher', () => {
|
||||
});
|
||||
|
||||
mockExecSync
|
||||
.mockReturnValueOnce('12345\n') // systemctl → PID
|
||||
.mockReturnValueOnce('512\n') // ps
|
||||
.mockReturnValueOnce('125\t/path\n'); // du → 125 MB
|
||||
|
||||
|
||||
Reference in New Issue
Block a user