pgStateProviderConformanceCases

Variable

Signature

const pgStateProviderConformanceCases: ConformanceTestCase<PgStateProviderConformanceContext>[];

postgres/src/conformance/state-provider-conformance.ts:297

Every state adapter contract case, including those that hold two transactions open at once, run through createPgStateAdapter over a provider, plus checks of the provider's classifyError. Run them one per test in your own test file against a context from createPgStateProviderConformanceContext. Works with any test runner.

Example

TypeScript

import { afterAll, beforeAll, test } from "vitest";

let pool: Pool;
let context: PgStateProviderConformanceContext;
beforeAll(async () => {
  pool = new Pool({ connectionString });
  context = await createPgStateProviderConformanceContext({
    createStateProvider: async () => createPgPoolStateProvider({ pool }),
    withNonTransactionContext: async (fn) => {
      const poolClient = await pool.connect();
      try {
        return await fn({ poolClient });
      } finally {
        poolClient.release();
      }
    },
  });
});
afterAll(async () => pool.end());

for (const conformanceCase of pgStateProviderConformanceCases) {
  test(conformanceCase.title, async () => {
    await conformanceCase.run(context);
  });
}

Used in guides

esc

Search guides, integrations and every exported symbol.

↑ ↓ to navigate↵ to open