mirror of
https://github.com/supabase/supabase.git
synced 2026-10-05 17:35:10 +03:00
Sorted all imports in all packages, `cms`, `design-system` and `ui-library` apps by running `pnpm format` on them. All changes in this PR are done by the script.
61 lines
1.5 KiB
TypeScript
61 lines
1.5 KiB
TypeScript
import { afterAll, expect, test } from 'vitest'
|
|
|
|
import pgMeta from '../src/index'
|
|
import { cleanupRoot, createTestDatabase } from './db/utils'
|
|
|
|
afterAll(async () => {
|
|
await cleanupRoot()
|
|
})
|
|
|
|
const withTestDatabase = (
|
|
name: string,
|
|
fn: (db: Awaited<ReturnType<typeof createTestDatabase>>) => Promise<void>
|
|
) => {
|
|
test(name, async () => {
|
|
const db = await createTestDatabase()
|
|
try {
|
|
await fn(db)
|
|
} finally {
|
|
await db.cleanup()
|
|
}
|
|
})
|
|
}
|
|
|
|
withTestDatabase('list config', async ({ executeQuery }) => {
|
|
const { sql, zod } = pgMeta.config.list()
|
|
const res = zod.parse(await executeQuery(sql))
|
|
|
|
// Test for a known config value
|
|
const autovacuumConfig = res.find(({ name }) => name === 'autovacuum')
|
|
expect(autovacuumConfig).toMatchInlineSnapshot(`
|
|
{
|
|
"boot_val": "on",
|
|
"category": "Autovacuum",
|
|
"context": "sighup",
|
|
"enumvals": null,
|
|
"extra_desc": null,
|
|
"group": "Autovacuum",
|
|
"max_val": null,
|
|
"min_val": null,
|
|
"name": "autovacuum",
|
|
"pending_restart": false,
|
|
"reset_val": "on",
|
|
"setting": "on",
|
|
"short_desc": "Starts the autovacuum subprocess.",
|
|
"source": "default",
|
|
"sourcefile": null,
|
|
"sourceline": null,
|
|
"subgroup": "",
|
|
"unit": null,
|
|
"vartype": "bool",
|
|
}
|
|
`)
|
|
})
|
|
|
|
withTestDatabase('list config with pagination', async ({ executeQuery }) => {
|
|
const { sql, zod } = pgMeta.config.list({ limit: 5, offset: 0 })
|
|
const res = zod.parse(await executeQuery(sql))
|
|
|
|
expect(res).toHaveLength(5)
|
|
})
|