Add needed constants and constructs to support PostgreSQL14 for tests
Signed-off-by: Jussi Hallila <jussi@hallila.com>
This commit is contained in:
@@ -0,0 +1,5 @@
|
||||
---
|
||||
'@backstage/backend-test-utils': patch
|
||||
---
|
||||
|
||||
Add needed constants and constructs to support PostgreSQL version 14 as test database
|
||||
@@ -59,6 +59,37 @@ describe('TestDatabases', () => {
|
||||
describe('each connect', () => {
|
||||
const dbs = TestDatabases.create();
|
||||
|
||||
itIfDocker(
|
||||
'obeys a provided connection string for postgres 14',
|
||||
async () => {
|
||||
const { host, port, user, password, stop } =
|
||||
await startPostgresContainer('postgres:14');
|
||||
|
||||
try {
|
||||
// Leave a mark
|
||||
process.env.BACKSTAGE_TEST_DATABASE_POSTGRES14_CONNECTION_STRING = `postgresql://${user}:${password}@${host}:${port}`;
|
||||
const input = await dbs.init('POSTGRES_14');
|
||||
await input.schema.createTable('a', table =>
|
||||
table.string('x').primary(),
|
||||
);
|
||||
await input.insert({ x: 'y' }).into('a');
|
||||
|
||||
// Look for the mark
|
||||
const database = input.client.config.connection.database;
|
||||
const output = knexFactory({
|
||||
client: 'pg',
|
||||
connection: { host, port, user, password, database },
|
||||
});
|
||||
// eslint-disable-next-line jest/no-standalone-expect
|
||||
await expect(output.select('x').from('a')).resolves.toEqual([
|
||||
{ x: 'y' },
|
||||
]);
|
||||
} finally {
|
||||
await stop();
|
||||
}
|
||||
},
|
||||
);
|
||||
|
||||
itIfDocker(
|
||||
'obeys a provided connection string for postgres 13',
|
||||
async () => {
|
||||
|
||||
@@ -24,6 +24,7 @@ import { getDockerImageForName } from '../util/getDockerImageForName';
|
||||
* @public
|
||||
*/
|
||||
export type TestDatabaseId =
|
||||
| 'POSTGRES_14'
|
||||
| 'POSTGRES_13'
|
||||
| 'POSTGRES_12'
|
||||
| 'POSTGRES_11'
|
||||
@@ -46,6 +47,13 @@ export type Instance = {
|
||||
|
||||
export const allDatabases: Record<TestDatabaseId, TestDatabaseProperties> =
|
||||
Object.freeze({
|
||||
POSTGRES_14: {
|
||||
name: 'Postgres 14.x',
|
||||
driver: 'pg',
|
||||
dockerImageName: getDockerImageForName('postgres:14'),
|
||||
connectionStringEnvironmentVariableName:
|
||||
'BACKSTAGE_TEST_DATABASE_POSTGRES14_CONNECTION_STRING',
|
||||
},
|
||||
POSTGRES_13: {
|
||||
name: 'Postgres 13.x',
|
||||
driver: 'pg',
|
||||
|
||||
Reference in New Issue
Block a user