mirror of
https://github.com/hedgedoc/hedgedoc.git
synced 2025-04-05 19:50:31 +00:00
Add config to tests in various places
Signed-off-by: David Mehren <git@herrmehren.de>
This commit is contained in:
parent
e8e82076d0
commit
18c6694bcb
4 changed files with 44 additions and 3 deletions
|
@ -4,8 +4,10 @@
|
|||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
*/
|
||||
|
||||
import { ConfigModule } from '@nestjs/config';
|
||||
import { Test, TestingModule } from '@nestjs/testing';
|
||||
import { getRepositoryToken } from '@nestjs/typeorm';
|
||||
import appConfigMock from '../../../config/app.config.mock';
|
||||
import { LoggerModule } from '../../../logger/logger.module';
|
||||
import { MediaUpload } from '../../../media/media-upload.entity';
|
||||
import { MediaModule } from '../../../media/media.module';
|
||||
|
@ -26,7 +28,15 @@ describe('Media Controller', () => {
|
|||
beforeEach(async () => {
|
||||
const module: TestingModule = await Test.createTestingModule({
|
||||
controllers: [MediaController],
|
||||
imports: [LoggerModule, MediaModule, NotesModule],
|
||||
imports: [
|
||||
ConfigModule.forRoot({
|
||||
isGlobal: true,
|
||||
load: [appConfigMock],
|
||||
}),
|
||||
LoggerModule,
|
||||
MediaModule,
|
||||
NotesModule,
|
||||
],
|
||||
})
|
||||
.overrideProvider(getRepositoryToken(AuthorColor))
|
||||
.useValue({})
|
||||
|
|
19
src/config/app.config.mock.ts
Normal file
19
src/config/app.config.mock.ts
Normal file
|
@ -0,0 +1,19 @@
|
|||
/*
|
||||
* SPDX-FileCopyrightText: 2021 The HedgeDoc developers (see AUTHORS file)
|
||||
*
|
||||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
*/
|
||||
|
||||
import { registerAs } from '@nestjs/config';
|
||||
|
||||
export default registerAs('appConfig', () => ({
|
||||
port: 3000,
|
||||
media: {
|
||||
backend: {
|
||||
use: 'filesystem',
|
||||
filesystem: {
|
||||
uploadPath: 'uploads',
|
||||
},
|
||||
},
|
||||
},
|
||||
}));
|
|
@ -4,8 +4,10 @@
|
|||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
*/
|
||||
|
||||
import { ConfigModule } from '@nestjs/config';
|
||||
import { Test, TestingModule } from '@nestjs/testing';
|
||||
import { getRepositoryToken } from '@nestjs/typeorm';
|
||||
import appConfigMock from '../config/app.config.mock';
|
||||
import { LoggerModule } from '../logger/logger.module';
|
||||
import { AuthorColor } from '../notes/author-color.entity';
|
||||
import { Note } from '../notes/note.entity';
|
||||
|
@ -17,6 +19,7 @@ import { AuthToken } from '../users/auth-token.entity';
|
|||
import { Identity } from '../users/identity.entity';
|
||||
import { User } from '../users/user.entity';
|
||||
import { UsersModule } from '../users/users.module';
|
||||
import { FilesystemBackend } from './backends/filesystem-backend';
|
||||
import { MediaUpload } from './media-upload.entity';
|
||||
import { MediaService } from './media.service';
|
||||
|
||||
|
@ -31,8 +34,17 @@ describe('MediaService', () => {
|
|||
provide: getRepositoryToken(MediaUpload),
|
||||
useValue: {},
|
||||
},
|
||||
FilesystemBackend,
|
||||
],
|
||||
imports: [
|
||||
ConfigModule.forRoot({
|
||||
isGlobal: true,
|
||||
load: [appConfigMock],
|
||||
}),
|
||||
LoggerModule,
|
||||
NotesModule,
|
||||
UsersModule,
|
||||
],
|
||||
imports: [LoggerModule, NotesModule, UsersModule],
|
||||
})
|
||||
.overrideProvider(getRepositoryToken(AuthorColor))
|
||||
.useValue({})
|
||||
|
|
|
@ -8,8 +8,8 @@ import { Inject, Injectable } from '@nestjs/common';
|
|||
import { ModuleRef } from '@nestjs/core';
|
||||
import { InjectRepository } from '@nestjs/typeorm';
|
||||
import * as FileType from 'file-type';
|
||||
import applicationConfig, { AppConfig } from 'src/config/app.config';
|
||||
import { Repository } from 'typeorm';
|
||||
import applicationConfig, { AppConfig } from '../config/app.config';
|
||||
import { ClientError, NotInDBError, PermissionError } from '../errors/errors';
|
||||
import { ConsoleLoggerService } from '../logger/console-logger.service';
|
||||
import { NotesService } from '../notes/notes.service';
|
||||
|
|
Loading…
Reference in a new issue