createPgStateProviderConformanceContext
FunctionSignature
function createPgStateProviderConformanceContext(options): Promise<PgStateProviderConformanceContext>;postgres/src/conformance/state-provider-conformance.ts:180
Prepares the context the pgStateProviderConformanceCases run against: migrates the
schema once through a provider from createStateProvider. Each case then builds its own adapter
over a new provider from it, with the tables cleared. Call it once the database is ready, such
as in beforeAll; the test file owns the database and releases it itself.
Parameters
- options
objectContext configuration. - options.createStateProvider(
) => Promise<PgStateProvider<any>>Creates the provider under test, over a database the suite may create tables in. Each case's adapter gets its own provider and closes it when the case ends, so closing one must not release resources the next one needs, such as the pool or the database connection. - options.stateAdapterOptions?
Omit<{ countCap?:number;generateJobId?: () => string;generateWorkerId?: () => string;jobIdType?:string;maxBlockersPerJob?:number;schema?:string;stateProvider:PgStateProvider<any>;tablePrefix?:string;validateJobId?: (id) =>boolean;validateWorkerId?: (id) =>boolean;workerIdType?:string; },"stateProvider">Options every adapter of the suite is created with, besides its provider, such as theschema,tablePrefixand ID types your application configures. The suite migrates and clears the tables they name. - options.withNonTransactionContext<
T>(fn) =>Promise<T>Runs the callback with a context of the provider's shape that is not inside a transaction (e.g. a pool client with noBEGIN), so the suite can checkisTransactionrejects it. - options.withSavepoint?<
T>(txCtx,fn) =>Promise<T>Runsfnin a savepoint oftxCtx's transaction, opened the way the application opens one, and passes it the savepoint's context: releases the savepoint whenfnresolves and rolls it back whenfnthrows, then rethrows. The suite checks that the provider'sonTransactionCommitandonTransactionRollbackfollow it; without it, those cases pass without checking anything.
Returns
Promise<PgStateProviderConformanceContext>