docs: brand logo in the README; test that the dialects table matches each dialect's capabilities
This commit is contained in:
File diff suppressed because one or more lines are too long
|
After Width: | Height: | Size: 14 KiB |
File diff suppressed because one or more lines are too long
|
After Width: | Height: | Size: 14 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 95 KiB |
@@ -1,4 +1,9 @@
|
||||
# restloom
|
||||
<h1 align="center">
|
||||
<picture>
|
||||
<source media="(prefers-color-scheme: dark)" srcset=".github/brand/logo-dark.svg">
|
||||
<img alt="restloom" src=".github/brand/logo-light.svg" height="110">
|
||||
</picture>
|
||||
</h1>
|
||||
|
||||
A REST API generated from your database's catalog. Name the schemas or tables to serve, and restloom reads their columns, types, keys and relations, and answers queries like this one:
|
||||
|
||||
|
||||
@@ -0,0 +1,36 @@
|
||||
import { test } from 'node:test';
|
||||
import assert from 'node:assert/strict';
|
||||
import { readFileSync } from 'node:fs';
|
||||
import { postgres } from '../packages/postgres/dist/index.js';
|
||||
import { mysql } from '../packages/mysql/dist/index.js';
|
||||
import { mssql } from '../packages/mssql/dist/index.js';
|
||||
import { sqlite } from '../packages/sqlite/dist/index.js';
|
||||
|
||||
// The table in docs/dialects.md is what readers compare databases by, on the
|
||||
// site too. It must say what each dialect's capabilities say.
|
||||
const DIALECTS = {
|
||||
'@crudy/restloom-postgres': postgres({}),
|
||||
'@crudy/restloom-mysql': mysql({}),
|
||||
'@crudy/restloom-mssql': mssql({}),
|
||||
'@crudy/restloom-sqlite': sqlite({ pragma() {} }),
|
||||
};
|
||||
|
||||
const rows = readFileSync(new URL('../docs/dialects.md', import.meta.url), 'utf8')
|
||||
.split('\n')
|
||||
.filter((line) => line.startsWith('| `@crudy/restloom-'))
|
||||
.map((line) => line.split('|').slice(1, -1).map((cell) => cell.trim()));
|
||||
|
||||
test('docs/dialects.md lists every dialect', () => {
|
||||
assert.deepEqual(rows.map((r) => r[0].replaceAll('`', '')).sort(), Object.keys(DIALECTS).sort());
|
||||
});
|
||||
|
||||
for (const [pkg, dialect] of Object.entries(DIALECTS)) {
|
||||
test(`docs/dialects.md says what ${pkg} can do`, () => {
|
||||
const [, , , written, estimated, rowSecurity, procedures] = rows.find((r) => r[0] === `\`${pkg}\``);
|
||||
const c = dialect.capabilities;
|
||||
assert.equal(/RETURNING|OUTPUT/.test(written), c.returning, 'written keys');
|
||||
assert.equal(estimated !== 'no', c.estimatedCount, 'estimated count');
|
||||
assert.equal(rowSecurity !== 'no', c.rowSecurity, 'row security');
|
||||
assert.equal(procedures !== 'none', c.procedures, 'procedures');
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user