Simplify instance details and clarify diagnostics
This commit is contained in:
@@ -0,0 +1,27 @@
|
||||
import { afterEach, beforeEach, expect, it, vi } from 'vitest';
|
||||
import { newFixture, type Fixture } from '../helpers/fixture.js';
|
||||
let fixture: Fixture;
|
||||
const name = 't5_zombie_theater_1';
|
||||
beforeEach(async () => {
|
||||
vi.resetModules(); fixture = await newFixture([name]);
|
||||
const { seedServerRegistry } = await import('../../src/lib/server/fleet/servers.js');
|
||||
await seedServerRegistry();
|
||||
});
|
||||
afterEach(async () => { await fixture.cleanup(); });
|
||||
|
||||
it('links only inventory whose exact content matches its library version', async () => {
|
||||
const { db } = await import('../../src/lib/server/db/index.js');
|
||||
const artifactId = Number(db().prepare("INSERT INTO scripts(name, target_rel_path, kind) VALUES ('utils', 'utils.dll', 'plugin')").run().lastInsertRowid);
|
||||
const versionId = Number(db().prepare("INSERT INTO script_versions(script_id, version, release_version, sha256, size) VALUES (?, 2, 'v1.1.0', 'known', 10)").run(artifactId).lastInsertRowid);
|
||||
const { recordScript } = await import('../../src/lib/server/fleet/inventory.js');
|
||||
recordScript(name, 'utils.dll', versionId, 'known', 10, 'native-create');
|
||||
recordScript(name, 'changed.dll', versionId, 'different', 12, 'native-create');
|
||||
recordScript(name, 'unknown.gsc', null, 'unknown', 2, 'native-create');
|
||||
const { GET } = await import('../../src/routes/api/servers/[name]/scripts/+server.js');
|
||||
const response = await GET({ params: { name } });
|
||||
expect(response.status).toBe(200);
|
||||
const { scripts } = await response.json();
|
||||
expect(scripts.find((item: { relPath: string }) => item.relPath === 'utils.dll')).toMatchObject({ artifactId, version: 2, releaseVersion: 'v1.1.0', kind: 'plugin' });
|
||||
expect(scripts.find((item: { relPath: string }) => item.relPath === 'changed.dll')).toMatchObject({ artifactId: null, version: null, releaseVersion: null });
|
||||
expect(scripts.find((item: { relPath: string }) => item.relPath === 'unknown.gsc')).toMatchObject({ artifactId: null, version: null, kind: 'script' });
|
||||
});
|
||||
Reference in New Issue
Block a user