mirror of
https://github.com/hedgedoc/hedgedoc.git
synced 2025-05-16 08:04:45 -04:00
Separate private and public API in TestSetup
Including both PublicApiModule and PrivateApiModule in the test setup lead to the API routes overwriting each other. This adds a router to separate the APIs as they are in the normal app. Signed-off-by: David Mehren <git@herrmehren.de>
This commit is contained in:
parent
474ca5deaf
commit
1cc797f13d
2 changed files with 26 additions and 12 deletions
|
@ -7,6 +7,7 @@ import { ConfigModule, ConfigService } from '@nestjs/config';
|
|||
import { NestExpressApplication } from '@nestjs/platform-express';
|
||||
import { Test, TestingModule } from '@nestjs/testing';
|
||||
import { TypeOrmModule } from '@nestjs/typeorm';
|
||||
import { RouterModule, Routes } from 'nest-router';
|
||||
|
||||
import { PrivateApiModule } from '../src/api/private/private-api.module';
|
||||
import { PublicApiModule } from '../src/api/public/public-api.module';
|
||||
|
@ -46,9 +47,27 @@ export class TestSetup {
|
|||
|
||||
public static async create(): Promise<TestSetup> {
|
||||
const testSetup = new TestSetup();
|
||||
const routes: Routes = [
|
||||
{
|
||||
path: '/api/v2',
|
||||
module: PublicApiModule,
|
||||
},
|
||||
{
|
||||
path: '/api/private',
|
||||
module: PrivateApiModule,
|
||||
},
|
||||
];
|
||||
|
||||
testSetup.moduleRef = await Test.createTestingModule({
|
||||
imports: [
|
||||
RouterModule.forRoutes(routes),
|
||||
TypeOrmModule.forRoot({
|
||||
type: 'sqlite',
|
||||
database: ':memory:',
|
||||
autoLoadEntities: true,
|
||||
synchronize: true,
|
||||
dropSchema: true,
|
||||
}),
|
||||
ConfigModule.forRoot({
|
||||
isGlobal: true,
|
||||
load: [
|
||||
|
@ -64,13 +83,6 @@ export class TestSetup {
|
|||
NotesModule,
|
||||
PermissionsModule,
|
||||
GroupsModule,
|
||||
TypeOrmModule.forRoot({
|
||||
type: 'sqlite',
|
||||
database: ':memory:',
|
||||
autoLoadEntities: true,
|
||||
synchronize: true,
|
||||
dropSchema: true,
|
||||
}),
|
||||
LoggerModule,
|
||||
AuthModule,
|
||||
UsersModule,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue