File size: 966 Bytes
c7d34c1
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
import { POSTGRES_SCHEMA } from './agent-state-postgres';
import { SQLITE_SCHEMA } from './agent-state-sqlite';
import assert from 'node:assert/strict';
import { readFileSync } from 'node:fs';
import path from 'node:path';
import { describe, it } from 'node:test';

describe('Agent state schema files', () => {
    it('keeps the SQLite runtime schema in sync with database/sqlite-agent-state.sql', () => {
        assert.equal(normalizeSql(SQLITE_SCHEMA), readSchemaFile('sqlite-agent-state.sql'));
    });

    it('keeps the PostgreSQL runtime schema in sync with database/postgres-agent-state.sql', () => {
        assert.equal(normalizeSql(POSTGRES_SCHEMA), readSchemaFile('postgres-agent-state.sql'));
    });
});

function readSchemaFile(filename: string): string {
    return normalizeSql(readFileSync(path.join(process.cwd(), 'database', filename), 'utf8'));
}

function normalizeSql(value: string): string {
    return value.replace(/\r\n/g, '\n').trim();
}