fix(reference): preserve station evidence and rollback schema
This commit is contained in:
+25
-3
@@ -24,9 +24,9 @@ describe('fixture reference compiler', () => {
|
||||
const resultVersion = result.version;
|
||||
const repository = new SqliteReferenceRepository(join(root, 'reference'));
|
||||
expect(await repository.types([34, 35, 587, 999999])).toEqual([
|
||||
{ id: 34, name: 'Tritanium', categoryId: 4, volume: 0.01 },
|
||||
{ id: 35, name: 'Pyerite', categoryId: 4, volume: 0.01 },
|
||||
{ id: 587, name: 'Rifter', categoryId: 6, volume: 2500 },
|
||||
expect.objectContaining({ id: 34, name: 'Tritanium', categoryId: 4, groupId: 18, volume: 0.01 }),
|
||||
expect.objectContaining({ id: 35, name: 'Pyerite', categoryId: 4, groupId: 18, volume: 0.01 }),
|
||||
expect.objectContaining({ id: 587, name: 'Rifter', categoryId: 6, groupId: 25, volume: 2500 }),
|
||||
]);
|
||||
expect(await repository.version()).toBe(resultVersion);
|
||||
repository.close();
|
||||
@@ -299,6 +299,28 @@ describe('fixture reference compiler', () => {
|
||||
} finally { await rm(root, { recursive: true, force: true }); }
|
||||
});
|
||||
|
||||
test('rejects a malformed PREVIOUS artifact before rollback', async () => {
|
||||
const { root, sources } = await fixtureDirectory();
|
||||
const directory = join(root, 'reference');
|
||||
try {
|
||||
const first = await new ReferenceCompiler({ directory, profile: 'fixture', sources: fixtureSources(sources) }).compile();
|
||||
expect(first.status).toBe('success');
|
||||
if (first.status !== 'success' || !first.version) throw new Error('initial fixture build did not publish a version');
|
||||
await writeFile(join(sources, 'reference-data.json'), `${await readFile(join(sources, 'reference-data.json'), 'utf8')}\n`);
|
||||
const second = await new ReferenceCompiler({ directory, profile: 'fixture', sources: fixtureSources(sources) }).compile();
|
||||
expect(second.status).toBe('success');
|
||||
if (second.status !== 'success' || !second.version) throw new Error('second fixture build did not publish a version');
|
||||
const manifest = await readReferenceManifest(directory);
|
||||
if (!manifest.previous) throw new Error('fixture build did not retain PREVIOUS');
|
||||
const previousPath = join(directory, 'databases', `${manifest.previous.version}.sqlite`);
|
||||
const malformed = new Database(previousPath);
|
||||
malformed.run('DROP INDEX type_search_normalized_name_idx');
|
||||
malformed.close();
|
||||
await expect(new ReferenceCompiler({ directory, profile: 'fixture', sources: fixtureSources(sources) }).rollback()).rejects.toThrow(/incompatible schema version/);
|
||||
expect((await readReferenceManifest(directory)).active?.version).toBe(second.version);
|
||||
} finally { await rm(root, { recursive: true, force: true }); }
|
||||
});
|
||||
|
||||
test('recovers a validated orphan database after manifest publication crash', async () => {
|
||||
const { root, sources } = await fixtureDirectory();
|
||||
const directory = join(root, 'reference');
|
||||
|
||||
Reference in New Issue
Block a user