warn when a host's kernel has cgroup memory accounting disabled

This commit is contained in:
Jarek Krochmalski committed 2026-09-12 16:24:13 +02:00
1 parent 5954e22297
commit 5512357a74
6 files changed
+121 -6

No files matched your search

+32
View File
@@ -0,0 +1,32 @@
import { describe, it, expect } from 'bun:test';
import { memorySupportFromInfo, MEMORY_SUPPORT_DOC_URL } from '../src/lib/utils/memory-support';
describe('memorySupportFromInfo', () => {
it('warns when MemoryLimit is false (cgroup memory off - Raspberry Pi case)', () => {
const r = memorySupportFromInfo({ MemoryLimit: false, SwapLimit: false });
expect(r.warn).toBe(true);
expect(r.memoryLimitSupported).toBe(false);
});
it('does not warn when MemoryLimit is true', () => {
const r = memorySupportFromInfo({ MemoryLimit: true, SwapLimit: true });
expect(r.warn).toBe(false);
expect(r.memoryLimitSupported).toBe(true);
});
it('treats a missing MemoryLimit as supported (no false alarm on older/partial info)', () => {
expect(memorySupportFromInfo({}).warn).toBe(false);
expect(memorySupportFromInfo(null).warn).toBe(false);
expect(memorySupportFromInfo(undefined).warn).toBe(false);
});
it('swap-only off does not warn (memory is what drives the 0 B display)', () => {
const r = memorySupportFromInfo({ MemoryLimit: true, SwapLimit: false });
expect(r.warn).toBe(false);
expect(r.swapLimitSupported).toBe(false);
});
it('doc url points at the manual anchor', () => {
expect(MEMORY_SUPPORT_DOC_URL).toBe('https://dockhand.pro/manual/#troubleshooting-rpi-memory');
});
});