telegram-mcp/cli/tests/unit/daemon-commands.test.ts
2026-11-05 14:26:28 +03:00

30 lines
922 B
TypeScript

import { describe, it, expect, vi, beforeEach, afterEach } from 'vitest';
import { mkdtempSync, rmSync } from 'node:fs';
import { join } from 'node:path';
import { tmpdir } from 'node:os';
import { DaemonPaths } from '../../src/lib/daemon/pid.js';
describe('DaemonPaths integration for commands', () => {
let tempDir: string;
beforeEach(() => {
vi.clearAllMocks();
tempDir = mkdtempSync(join(tmpdir(), 'tg-daemon-cmd-'));
});
afterEach(() => {
rmSync(tempDir, { recursive: true, force: true });
});
it('status reports not running when no PID file', () => {
const paths = new DaemonPaths(tempDir, 'default');
expect(paths.readPid()).toBeNull();
expect(paths.socketExists()).toBe(false);
});
it('status reports PID when PID file exists', () => {
const paths = new DaemonPaths(tempDir, 'default');
paths.writePid(99999);
expect(paths.readPid()).toBe(99999);
});
});