test: add and use a mocked DatabaseConfig

Signed-off-by: David Mehren <git@herrmehren.de>
This commit is contained in:
David Mehren 2022-03-06 17:27:27 +01:00
parent 89297e748f
commit 513d64493e
2 changed files with 24 additions and 0 deletions

View file

@ -0,0 +1,22 @@
/*
* SPDX-FileCopyrightText: 2022 The HedgeDoc developers (see AUTHORS file)
*
* SPDX-License-Identifier: AGPL-3.0-only
*/
import { registerAs } from '@nestjs/config';
import { DatabaseDialect } from '../database-dialect.enum';
import { DatabaseConfig } from '../database.config';
export default registerAs(
'databaseConfig',
(): DatabaseConfig => ({
dialect: (process.env.HEDGEDOC_TEST_DB_TYPE || 'sqlite') as DatabaseDialect,
database: 'hedgedoc',
password: 'hedgedoc',
host: 'localhost',
port: 0,
storage: '',
username: 'hedgedoc',
}),
);

View file

@ -23,6 +23,7 @@ import { DatabaseConfig } from '../src/config/database.config';
import appConfigMock from '../src/config/mock/app.config.mock';
import authConfigMock from '../src/config/mock/auth.config.mock';
import customizationConfigMock from '../src/config/mock/customization.config.mock';
import databaseConfigMock from '../src/config/mock/database.config.mock';
import externalServicesConfigMock from '../src/config/mock/external-services.config.mock';
import mediaConfigMock from '../src/config/mock/media.config.mock';
import noteConfigMock from '../src/config/mock/note.config.mock';
@ -199,6 +200,7 @@ export class TestSetupBuilder {
isGlobal: true,
load: [
appConfigMock,
databaseConfigMock,
noteConfigMock,
authConfigMock,
mediaConfigMock,