Drift now covers all three destinations
This commit is contained in:
@@ -0,0 +1,51 @@
|
||||
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
|
||||
import { mkdir, writeFile } from 'node:fs/promises';
|
||||
import { join } from 'node:path';
|
||||
import { newFixture, type Fixture } from '../helpers/fixture.js';
|
||||
|
||||
let fixture: Fixture;
|
||||
|
||||
beforeEach(async () => {
|
||||
vi.resetModules();
|
||||
fixture = await newFixture(['t5_kino_1']);
|
||||
delete process.env.KOMODO_ADDRESS;
|
||||
delete process.env.RCON_PASSWORD;
|
||||
// Ensure the three per-kind destinations exist under the fixture tree.
|
||||
await mkdir(join(fixture.t5, 't5_kino_1', 'runtime/plutonium/storage/t5/raw/scripts/sp'), { recursive: true });
|
||||
await mkdir(join(fixture.t5, 't5_kino_1', 'configs'), { recursive: true });
|
||||
await mkdir(join(fixture.t5, 't5_kino_1', 'runtime/plutonium/plugins'), { recursive: true });
|
||||
});
|
||||
|
||||
afterEach(async () => {
|
||||
await fixture.cleanup();
|
||||
});
|
||||
|
||||
describe('drift scanning', () => {
|
||||
it('detects untracked files across script, config, and plugin destinations', async () => {
|
||||
const { seedServerRegistry } = await import('../../src/lib/server/fleet/servers.js');
|
||||
const { scanServerDrift } = await import('../../src/lib/server/fleet/drift.js');
|
||||
await seedServerRegistry();
|
||||
|
||||
// Drop one stray file in each managed destination.
|
||||
const server = 't5_kino_1';
|
||||
await writeFile(
|
||||
join(fixture.t5, server, 'runtime/plutonium/storage/t5/raw/scripts/sp', 'stray.gsc'),
|
||||
'main(){}\n'
|
||||
);
|
||||
await writeFile(
|
||||
join(fixture.t5, server, 'configs', 'stray.cfg'),
|
||||
'set foo "bar"\n'
|
||||
);
|
||||
await writeFile(
|
||||
join(fixture.t5, server, 'runtime/plutonium/plugins', 'stray.dll'),
|
||||
Buffer.from([0xde, 0xad])
|
||||
);
|
||||
|
||||
const drift = await scanServerDrift(server);
|
||||
const byKind = Object.fromEntries(drift.map((d) => [d.kind, d.relPath]));
|
||||
expect(byKind.script).toBe('stray.gsc');
|
||||
expect(byKind.config).toBe('stray.cfg');
|
||||
expect(byKind.plugin).toBe('stray.dll');
|
||||
expect(drift.length).toBe(3);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user