This repository has been archived by the owner on Feb 10, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
PgRepositoryIntegration.test.ts
59 lines (52 loc) · 3.01 KB
/
PgRepositoryIntegration.test.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
// Copyright (c) 2023. Heusala Group Oy <[email protected]>. All rights reserved.
import "../jest/matchers/index";
import { RepositoryUtils } from "../core/data/utils/RepositoryUtils";
import { LogLevel } from "../core/types/LogLevel";
import { CrudRepositoryImpl } from "../core/data/types/CrudRepositoryImpl";
import { allRepositoryTests } from "../core/data/tests/allRepositoryTests";
import { setCrudRepositoryLogLevel } from "../core/data/types/CrudRepository";
import { PersisterMetadataManagerImpl } from "../core/data/persisters/types/PersisterMetadataManagerImpl";
import { parseNonEmptyString } from "../core/types/String";
import { PgPersister } from "./PgPersister";
import { PgOidParserUtils } from "../core/data/persisters/pg/utils/PgOidParserUtils";
import { PersisterType } from "../core/data/persisters/types/PersisterType";
export const TEST_SCOPES : readonly string[] = (parseNonEmptyString(process?.env?.TEST_SCOPES) ?? '').split(/[,| :;+]+/);
export const POSTGRES_HOSTNAME : string = parseNonEmptyString(process?.env?.TEST_POSTGRES_HOSTNAME) ?? 'localhost';
export const POSTGRES_USERNAME : string = parseNonEmptyString(process?.env?.TEST_POSTGRES_USERNAME) ?? 'hg';
export const POSTGRES_PASSWORD : string = parseNonEmptyString(process?.env?.TEST_POSTGRES_PASSWORD) ?? '';
export const POSTGRES_DATABASE : string = parseNonEmptyString(process?.env?.TEST_POSTGRES_DATABASE) ?? 'hg';
export const POSTGRES_TABLE_PREFIX : string = parseNonEmptyString(process?.env?.TEST_POSTGRES_TABLE_PREFIX) ?? 'prefix_';
export const POSTGRES_CHARSET : string = parseNonEmptyString(process?.env?.TEST_POSTGRES_CHARSET ) ?? '';
export const POSTGRES_SSL : boolean | undefined = ['1', 'TRUE', 'ENABLED', 'ON'].includes((parseNonEmptyString(process?.env?.TEST_POSTGRES_SSL ) ?? '').toUpperCase());
export const INTEGRATION_TESTS_ENABLED : boolean = TEST_SCOPES.includes('integration') && !!POSTGRES_PASSWORD;
(INTEGRATION_TESTS_ENABLED ? describe : describe.skip)('Repository integrations', () => {
beforeAll(() => {
RepositoryUtils.setLogLevel(LogLevel.NONE);
setCrudRepositoryLogLevel(LogLevel.NONE);
CrudRepositoryImpl.setLogLevel(LogLevel.NONE);
PersisterMetadataManagerImpl.setLogLevel(LogLevel.NONE);
PgPersister.setLogLevel(LogLevel.NONE);
PgOidParserUtils.setLogLevel(LogLevel.NONE);
});
describe('PostgreSQL', () => {
allRepositoryTests(
PersisterType.POSTGRESQL,
() => new PgPersister(
POSTGRES_HOSTNAME,
POSTGRES_USERNAME,
POSTGRES_PASSWORD,
POSTGRES_DATABASE,
POSTGRES_SSL,
POSTGRES_TABLE_PREFIX,
undefined,
undefined,
undefined,
100,
true,
undefined,
undefined,
undefined,
)
);
});
});