CH-J Server Managerspráva serverů přes SSH
Menu
Vydané zdroje

CH-J Server Manager

Procházejte adresáře a soubory konkrétního vydání aplikace.

Stáhnout zdroje ZIP
CH-J Proprietary Software License 1.14

Zdroje jsou zveřejněny pod CH-J Proprietary Software License 1.14. Jejich dostupnost nemění licenční podmínky ani neposkytuje další oprávnění.

1,3 KB · 27 řádkůStáhnout soubor
1"use strict";
3const test = require("node:test");
4const assert = require("node:assert/strict");
5const fs = require("node:fs");
6const os = require("node:os");
7const path = require("node:path");
8const { LogService, MAX_LIMIT, normalizeLimit } = require("../src/main/logging/logService");
10test("log service returns a bounded tail without a partial first record", async (t) => {
11 const root = fs.mkdtempSync(path.join(os.tmpdir(), "chj-log-"));
12 t.after(() => fs.rmSync(root, { recursive: true, force: true }));
13 const logPath = path.join(root, "core.log");
14 fs.writeFileSync(logPath, "first-record\nsecond-record\nthird-record\n");
15 const result = await new LogService(logPath).readTail({ maxBytes: 29 });
16 assert.equal(result.text, "second-record\nthird-record\n");
17 assert.equal(result.truncated, true);
18 assert.equal(result.size, 40);
19 assert.match(result.readAt, /^\d{4}-\d{2}-\d{2}T/);
20});
22test("log service handles a missing log and caps read limits", async (t) => {
23 const root = fs.mkdtempSync(path.join(os.tmpdir(), "chj-log-missing-"));
24 t.after(() => fs.rmSync(root, { recursive: true, force: true }));
25 assert.equal(normalizeLimit(Number.MAX_SAFE_INTEGER), MAX_LIMIT);
26 assert.equal((await new LogService(path.join(root, "missing.log")).readTail()).text, "");
27});

SHA-256: 83099441b516dc585e5dbebf22dc6c8fa3df77e539538f2b8673e6869e7bf137

SHA-256 archivu: 5ac91caf4fa32a6fdb114f2430deed486fbe7489d5eea343d1f034169fafb5e0