refactor(ground): remove the unversioned-file fallback
- A file without a schema number is refused again; the example output in RAG/pierzainer_ground now has schema 2, so the temporary path is not needed. - The legacy fixture is removed; tests cover the missing and null schema numbers and a pier without a ground object. Co-Authored-By: Claude Haiku 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
bfd41d7c8d
commit
0e70cfb969
3 files changed
+9
-417
No files matched your search
@@ -1,4 +1,3 @@
|
||||
import { readFileSync } from 'node:fs';
|
||||
import { describe, expect, it } from 'vitest';
|
||||
import { groundElFor, parseGroundModel } from '../src/core/ground-model';
|
||||
import { changedKeys, overrideKeys, revertDraft, type PierValues } from '../src/core/changes';
|
||||
@@ -89,26 +88,17 @@ describe('지형 격자 (schema 2)', () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe('번호 없는 옛 지반 모델 (B′: 임시 경로)', () => {
|
||||
// examples/out/ground_model.json as written before the schema number existed (P1–P6, same values as the report).
|
||||
const LEGACY = readFileSync(new URL('./fixtures/ground-model-legacy.json', import.meta.url), 'utf-8');
|
||||
|
||||
it('reads the unversioned file and reports it as schema 1', () => {
|
||||
const m = parseGroundModel(LEGACY);
|
||||
expect(m.schema).toBe(2); // normalised to the current schema
|
||||
expect(m.piers.map((p) => p.id)).toEqual(['P1', 'P2', 'P3', 'P4', 'P5', 'P6']);
|
||||
expect(groundElFor(m, 'P1')).toBe(29.355);
|
||||
expect(m.piers[0].excelEl).toBe(28.931);
|
||||
describe('형식 번호 검사', () => {
|
||||
it('refuses a file with no schema number (the B′ fallback is removed)', () => {
|
||||
expect(() => parseGroundModel(JSON.stringify({ piers: [{ id: 'P1', ground: { center: 29.355, excel: 28.931 } }] }))).toThrow('형식 번호 undefined');
|
||||
});
|
||||
|
||||
it('refuses a pier that has no ground object (a renamed field must not load as empty values)', () => {
|
||||
const data = JSON.parse(LEGACY);
|
||||
delete data.piers[1].ground;
|
||||
expect(() => parseGroundModel(JSON.stringify(data))).toThrow('P2: 지반 값(ground)이 없습니다');
|
||||
it('refuses a null schema number', () => {
|
||||
expect(() => parseGroundModel('{"schema": null, "piers": []}')).toThrow('형식 번호 null');
|
||||
});
|
||||
|
||||
it('refuses a null schema number instead of treating it as missing', () => {
|
||||
expect(() => parseGroundModel(LEGACY.replace('{', '{"schema": null,'))).toThrow('형식 번호 null');
|
||||
it('refuses a pier that has no ground object', () => {
|
||||
expect(() => parseGroundModel(JSON.stringify({ schema: 1, piers: [{ id: 'P2' }] }))).toThrow('P2: 지반 값(ground)이 없습니다');
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
Reference in new issue
Block a user