20 lines
1.3 KiB
JavaScript
20 lines
1.3 KiB
JavaScript
import { test } from 'node:test';
|
|
import assert from 'node:assert/strict';
|
|
import { formatDockerEvent } from '../src/servers/dockerAdapter.js';
|
|
|
|
const ev = (o) => JSON.stringify({ time: 1793549403, ...o });
|
|
|
|
test('Docker-Ereignisse werden lesbar, App-Container markiert', () => {
|
|
const start = formatDockerEvent(ev({ Type: 'container', Action: 'start', Actor: { ID: 'abc', Attributes: { name: 'cs2mv-knife1', image: 'joedwards32/cs2:latest', 'cs2-mapveto': '1' } } }));
|
|
assert.match(start, /Container cs2mv-knife1 \[Mapveto\] gestartet \(joedwards32\/cs2:latest\)$/);
|
|
const die = formatDockerEvent(ev({ Type: 'container', Action: 'die', Actor: { ID: 'abc', Attributes: { name: 'gitea', exitCode: '137' } } }));
|
|
assert.match(die, /Container gitea beendet \(Exit-Code 137\)$/);
|
|
assert.match(formatDockerEvent(ev({ Type: 'image', Action: 'pull', Actor: { ID: 'joedwards32/cs2:latest', Attributes: { name: 'joedwards32/cs2' } } })), /Image joedwards32\/cs2 geladen/);
|
|
});
|
|
|
|
test('Healthchecks, Mounts und kaputte Zeilen fallen weg', () => {
|
|
assert.equal(formatDockerEvent(ev({ Type: 'container', Action: 'exec_start: /bin/sh -c mysql --password=geheim', Actor: { Attributes: {} } })), null);
|
|
assert.equal(formatDockerEvent(ev({ Type: 'volume', Action: 'mount', Actor: { Attributes: {} } })), null);
|
|
assert.equal(formatDockerEvent('kein json'), null);
|
|
});
|