fix(reference): select verified station deterministically
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import { expect, test } from 'bun:test';
|
||||
import { cp, mkdtemp, readFile, rm, writeFile } from 'node:fs/promises';
|
||||
import { Database } from 'bun:sqlite';
|
||||
import { join } from 'node:path';
|
||||
import { tmpdir } from 'node:os';
|
||||
import { ReferenceCompiler, SqliteReferenceRepository, readReferenceManifest } from '../src/lib/server/reference';
|
||||
@@ -15,8 +16,8 @@ test('reference readers search normalized types and expose group/category/system
|
||||
const universe = JSON.parse(await readFile(universePath, 'utf8')) as Record<string, unknown>;
|
||||
universe.regions = { '10000001': { region_id: 10000001, name: 'The Forge' } };
|
||||
universe.constellations = { '20000020': { constellation_id: 20000020, name: 'Kimotoro', region_id: 10000001 } };
|
||||
universe.stations = { '60003760': { station_id: 60003760, system_id: 30000142, name: 'Jita IV - Moon 4 - Caldari Navy Assembly Plant', type_id: 587, owner_id: 1000035, position: { x: 1, y: 2, z: 3 } } };
|
||||
(universe.systems as Record<string, Record<string, unknown>>)['30000142'].stations = [60003761];
|
||||
universe.stations = { '60003761': { station_id: 60003761, system_id: 30000142, name: 'Jita IV - Moon 4 - Caldari Navy Assembly Plant', type_id: 587, owner_id: 1000035, position: { x: 1, y: 2, z: 3 } } };
|
||||
(universe.systems as Record<string, Record<string, unknown>>)['30000142'].stations = [60003760];
|
||||
await writeFile(universePath, JSON.stringify(universe));
|
||||
|
||||
const result = await new ReferenceCompiler({ directory, profile: 'fixture', sources: fixtureSources(sources) }).compile();
|
||||
@@ -32,10 +33,13 @@ test('reference readers search normalized types and expose group/category/system
|
||||
const stations = await reader.stations({ systemId: 30000142 });
|
||||
expect(stations).toHaveLength(2);
|
||||
expect(stations).toEqual([
|
||||
{ id: 60003760, systemId: 30000142, systemName: 'Jita', regionId: 10000001, evidence: 'verified', sourceVerified: true, name: 'Jita IV - Moon 4 - Caldari Navy Assembly Plant', typeId: 587, ownerId: 1000035, x: 1, y: 2, z: 3 },
|
||||
{ id: 60003761, systemId: 30000142, systemName: 'Jita', regionId: 10000001, evidence: 'system_listed', sourceVerified: false, name: null, typeId: null, ownerId: null, x: null, y: null, z: null },
|
||||
{ id: 60003760, systemId: 30000142, systemName: 'Jita', regionId: 10000001, evidence: 'system_listed', sourceVerified: false, name: null, typeId: null, ownerId: null, x: null, y: null, z: null },
|
||||
{ id: 60003761, systemId: 30000142, systemName: 'Jita', regionId: 10000001, evidence: 'verified', sourceVerified: true, name: 'Jita IV - Moon 4 - Caldari Navy Assembly Plant', typeId: 587, ownerId: 1000035, x: 1, y: 2, z: 3 },
|
||||
]);
|
||||
expect(await reader.stations({ query: 'assembly' })).toEqual([stations[0]]);
|
||||
const db = new Database(reader.databasePath, { readonly: true, strict: true });
|
||||
try { expect(db.query<{ station_id: number }, []>('SELECT station_id FROM stations WHERE source_verified = 1 ORDER BY station_id LIMIT 1').get()?.station_id).toBe(60003761); }
|
||||
finally { db.close(); }
|
||||
expect(await reader.stations({ query: 'assembly' })).toEqual([stations[1]]);
|
||||
const pinned = reader.pin();
|
||||
try { expect((await pinned.searchTypesByName('pyerite'))[0]?.id).toBe(35); }
|
||||
finally { pinned.close(); }
|
||||
|
||||
Reference in New Issue
Block a user