mirror of
https://github.com/gristlabs/grist-core.git
synced 2026-03-02 04:09:24 +00:00
add a script for copying schema information from python to typescript
There was no script for updating typescript schema information after a python-based document migration. Moving one in here, along with its test. Tweaked the code slightly to work with grist-core's directory structure. Also fixed a formatting error in mocha calls that was resulting in some root tests not running.
This commit is contained in:
41
test/server/generateInitialDocSql.ts
Normal file
41
test/server/generateInitialDocSql.ts
Normal file
@@ -0,0 +1,41 @@
|
||||
import { getAppRoot } from 'app/server/lib/places';
|
||||
import { createTmpDir } from 'test/server/docTools';
|
||||
import * as testUtils from 'test/server/testUtils';
|
||||
|
||||
import { assert } from 'chai';
|
||||
import * as childProcess from 'child_process';
|
||||
import * as fse from 'fs-extra';
|
||||
import * as path from 'path';
|
||||
import * as util from 'util';
|
||||
|
||||
const execFile = util.promisify(childProcess.execFile);
|
||||
|
||||
describe('generateInitialDocSql', function() {
|
||||
this.timeout(10000);
|
||||
|
||||
let tmpDir: string;
|
||||
|
||||
testUtils.setTmpLogLevel('fatal');
|
||||
|
||||
before(async function() {
|
||||
tmpDir = await createTmpDir();
|
||||
});
|
||||
|
||||
it('confirms schema and sql files are up to date (run "./build schema" on failure)', async function() {
|
||||
let root = getAppRoot();
|
||||
if (await fse.pathExists(path.join(root, 'core'))) {
|
||||
root = path.join(root, 'core');
|
||||
}
|
||||
const newSchemaTs = path.join(tmpDir, 'schema.ts');
|
||||
const newSqlTs = path.join(tmpDir, 'sql.ts');
|
||||
const currentSchemaTs = path.join(root, 'app/common/schema.ts');
|
||||
const currentSqlTs = path.join(root, 'app/server/lib/initialDocSql.ts');
|
||||
await execFile(path.join(getAppRoot(), 'buildtools/update_schema.sh'), [
|
||||
newSchemaTs, newSqlTs,
|
||||
], { env: process.env });
|
||||
assert.equal((await fse.readFile(newSchemaTs)).toString(),
|
||||
(await fse.readFile(currentSchemaTs)).toString());
|
||||
assert.equal((await fse.readFile(newSqlTs)).toString(),
|
||||
(await fse.readFile(currentSqlTs)).toString());
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user