Add Prettier and ESLint tooling (Refs #77)
This commit is contained in:
@@ -3,16 +3,31 @@ 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]);
|
||||
vi.resetModules();
|
||||
fixture = await newFixture([name]);
|
||||
const { seedServerRegistry } = await import('../../src/lib/server/fleet/servers.js');
|
||||
await seedServerRegistry();
|
||||
});
|
||||
afterEach(async () => { await fixture.cleanup(); });
|
||||
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 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');
|
||||
@@ -21,7 +36,13 @@ it('links only inventory whose exact content matches its library version', async
|
||||
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' });
|
||||
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