Fix initial artifact deployment and drift file replacement
This commit is contained in:
@@ -53,6 +53,40 @@ async function promotedConfig() {
|
||||
}
|
||||
|
||||
describe('server creation map selection', () => {
|
||||
it('installs only promoted scope-matching scripts and plugins before first boot', async () => {
|
||||
const { createScript } = await import('../../src/lib/server/fleet/scripts.js');
|
||||
const { db } = await import('../../src/lib/server/db/index.js');
|
||||
const { destOfKind } = await import('../../src/lib/server/config.js');
|
||||
const { getServerScript } = await import('../../src/lib/server/fleet/inventory.js');
|
||||
const { createServer } = await import('../../src/lib/server/fleet/create.js');
|
||||
const { komodoDeploy } = await import('../../src/lib/server/integrations/komodo.js');
|
||||
const { scanServerDrift } = await import('../../src/lib/server/fleet/drift.js');
|
||||
const artifacts = [
|
||||
{ kind: 'script' as const, target: 'zm_spawn_fix.gsc', scopeType: 'game' as const, scopeValue: 't5', promoted: true, expected: true },
|
||||
{ kind: 'plugin' as const, target: 'plugin.dll', scopeType: 'map' as const, scopeValue: 'zombie_cosmodrome', promoted: true, expected: true },
|
||||
{ kind: 'script' as const, target: 'other.gsc', scopeType: 'map' as const, scopeValue: 'zombie_theater', promoted: true, expected: false },
|
||||
{ kind: 'script' as const, target: 'draft.gsc', scopeType: 'game' as const, scopeValue: 't5', promoted: false, expected: false }
|
||||
].map((a) => {
|
||||
const { script, version } = createScript({ name: a.target, kind: a.kind, targetRelPath: a.target,
|
||||
scopeType: a.scopeType, scopeValue: a.scopeValue, content: Buffer.from(a.target) });
|
||||
if (a.promoted) db().prepare('UPDATE scripts SET current_version_id = ? WHERE id = ?').run(version.id, script.id);
|
||||
return { ...a, version };
|
||||
});
|
||||
vi.mocked(komodoDeploy).mockImplementationOnce(async () => {
|
||||
for (const a of artifacts) {
|
||||
const path = join(destOfKind(serverName, a.kind), a.target);
|
||||
expect(existsSync(path)).toBe(a.expected);
|
||||
if (a.expected) {
|
||||
expect(await readFile(path)).toEqual(a.version.content);
|
||||
expect(getServerScript(serverName, a.target)).toMatchObject({ script_version_id: a.version.id, source: 'create' });
|
||||
}
|
||||
}
|
||||
return { ok: true };
|
||||
});
|
||||
expect(await createServer(input)).toMatchObject({ ok: true });
|
||||
expect(await scanServerDrift(serverName)).toEqual([]);
|
||||
});
|
||||
|
||||
it('keeps Plutainer defaults without a baseline and overrides the map before rotation', async () => {
|
||||
const { createServer } = await import('../../src/lib/server/fleet/create.js');
|
||||
const { komodoCreateDeployment, komodoDeploy } = await import('../../src/lib/server/integrations/komodo.js');
|
||||
@@ -100,6 +134,11 @@ describe('server creation map selection', () => {
|
||||
|
||||
it('removes the generated config and inventory if deployment fails', async () => {
|
||||
await promotedConfig();
|
||||
const { createScript } = await import('../../src/lib/server/fleet/scripts.js');
|
||||
const { db } = await import('../../src/lib/server/db/index.js');
|
||||
const { script, version } = createScript({ name: 'spawn fix', kind: 'script', scopeType: 'game', scopeValue: 't5',
|
||||
targetRelPath: 'zm_spawn_fix.gsc', content: Buffer.from('main(){}') });
|
||||
db().prepare('UPDATE scripts SET current_version_id = ? WHERE id = ?').run(version.id, script.id);
|
||||
const { createServer } = await import('../../src/lib/server/fleet/create.js');
|
||||
const { komodoDeploy } = await import('../../src/lib/server/integrations/komodo.js');
|
||||
const { getServer } = await import('../../src/lib/server/fleet/servers.js');
|
||||
@@ -108,6 +147,7 @@ describe('server creation map selection', () => {
|
||||
expect(await createServer(input)).toMatchObject({ ok: false, kind: 'komodo' });
|
||||
expect(getServer(serverName)).toBeUndefined();
|
||||
expect(getServerScript(serverName, 'dedicated_sp.cfg')).toBeUndefined();
|
||||
expect(getServerScript(serverName, 'zm_spawn_fix.gsc')).toBeUndefined();
|
||||
expect(existsSync(join(fixture.t5, serverName))).toBe(false);
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user