Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

테스트에서 PinoLogger 모킹 / 테스트 오류 수정 / 검색 가중치 변경 #244

Merged
merged 3 commits into from
Dec 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -281,3 +281,4 @@ Network Trash Folder
Temporary Items
.apdisk

**/*.pem
2 changes: 1 addition & 1 deletion backend/src/search/query/builder/FilterQueryBuilder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ const createMatchFilter = (field: string, value: string, weight: number) => ({
});

export const FilterBuilders = {
FILTER_TERM_NAME_KEYWORD: (query: string, weight: number = 20) =>
FILTER_TERM_NAME_KEYWORD: (query: string, weight: number = 50) =>
createTermFilter('name.keyword', query, weight),
FILTER_MATCH_NAME: (token: string, weight: number = 15) =>
createMatchFilter('name', token, weight),
Expand Down
13 changes: 9 additions & 4 deletions backend/test/config/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { Test, TestingModule } from '@nestjs/testing';
import { initializeTransactionalContext } from 'typeorm-transactional';
import { initDataSource } from '@test/config/datasource.config';
import { AppModule } from '@src/AppModule';
import { PinoLogger } from 'nestjs-pino';

interface TestSetup {
app: INestApplication;
Expand All @@ -22,6 +23,10 @@ export async function initializeIntegrationTestEnvironment(): Promise<TestSetup>
})
.overrideProvider(DataSource)
.useValue(dataSource)
.overrideProvider(PinoLogger)
.useValue({
error: jest.fn(),
})
.compile();
const app = module.createNestApplication();
app.useGlobalPipes(new ValidationPipe({ transform: true }));
Expand All @@ -44,10 +49,10 @@ export async function truncateTables(dataSource: DataSource) {
await queryRunner.query('SET FOREIGN_KEY_CHECKS = 0;');

const tables = await queryRunner.query(`
SELECT TABLE_NAME
FROM information_schema.tables
WHERE table_schema = DATABASE();
`);
SELECT TABLE_NAME
FROM information_schema.tables
WHERE table_schema = DATABASE();
`);

for (const { TABLE_NAME } of tables) {
await queryRunner.query(`TRUNCATE TABLE \`${TABLE_NAME}\`;`);
Expand Down
6 changes: 5 additions & 1 deletion backend/test/course/course.service.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,11 @@ describe('CourseService', () => {
currentPage,
pageSize,
);
expect(result).toEqual(expectedResponse);
expect(result).toEqual(
expect.objectContaining({
courses: expectedResponse.courses,
}),
);
});

describe('특정 코스를 조회할 때', () => {
Expand Down
Loading