pgsql-test
Version:
pgsql-test offers isolated, role-aware, and rollback-friendly PostgreSQL environments for integration tests — giving developers realistic test coverage without external state pollution
21 lines (20 loc) • 751 B
JavaScript
import { DbAdmin as BaseDbAdmin } from 'pgsql-client';
// Extend DbAdmin from pgsql-client with test-specific methods
export class DbAdmin extends BaseDbAdmin {
constructor(config, verbose = false, roleConfig) {
super(config, verbose, roleConfig);
}
async createSeededTemplate(templateName, adapter) {
const seedDb = this.config.database;
this.create(seedDb);
await adapter.seed({
admin: this,
config: this.config,
pg: null, // placeholder for PgTestClient
connect: null // placeholder for connection factory
});
this.cleanupTemplate(templateName);
this.createTemplateFromBase(seedDb, templateName);
this.drop(seedDb);
}
}