From 6ab936611f29d4f9c8f9e438d9af8f8727bbd331 Mon Sep 17 00:00:00 2001 From: fru1tworld Date: Tue, 3 Dec 2024 15:46:59 +0900 Subject: [PATCH] =?UTF-8?q?feat:=20space=20update=20=EB=A1=9C=EC=A7=81=20?= =?UTF-8?q?=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/space/space.controller.spec.ts | 22 ------------------- .../backend/src/space/space.controller.ts | 9 ++++++-- 2 files changed, 7 insertions(+), 24 deletions(-) diff --git a/packages/backend/src/space/space.controller.spec.ts b/packages/backend/src/space/space.controller.spec.ts index 00df38f..887d550 100644 --- a/packages/backend/src/space/space.controller.spec.ts +++ b/packages/backend/src/space/space.controller.spec.ts @@ -120,26 +120,4 @@ describe('SpaceController', () => { ); }); }); - - describe('updateSpace', () => { - it('스페이스가 존재하지 않을 경우 404 오류를 던져야 한다', async () => { - const spaceId = '123'; - (spaceService.existsById as jest.Mock).mockResolvedValue(false); - - await expect(spaceController.updateSpace(spaceId)).rejects.toThrow( - HttpException, - ); - - expect(spaceService.existsById).toHaveBeenCalledWith(spaceId); - }); - - it('스페이스가 존재할 경우 오류를 던지지 않아야 한다', async () => { - const spaceId = '123'; - (spaceService.existsById as jest.Mock).mockResolvedValue(true); - - await expect(spaceController.updateSpace(spaceId)).resolves.not.toThrow(); - - expect(spaceService.existsById).toHaveBeenCalledWith(spaceId); - }); - }); }); diff --git a/packages/backend/src/space/space.controller.ts b/packages/backend/src/space/space.controller.ts index f35034c..c6f076e 100644 --- a/packages/backend/src/space/space.controller.ts +++ b/packages/backend/src/space/space.controller.ts @@ -17,6 +17,7 @@ import { ERROR_MESSAGES } from '../common/constants/error.message.constants'; import { GUEST_USER_ID } from '../common/constants/space.constants'; import { CreateSpaceDto } from './dto/create.space.dto'; import { SpaceService } from './space.service'; +import { UpdateSpaceDto } from './dto/update.space.dto'; @ApiTags('space') @Controller('space') @@ -143,8 +144,11 @@ export class SpaceController { @ApiOperation({ summary: '스페이스 업데이트' }) @ApiResponse({ status: 201, description: '스페이스 업데이트 성공' }) @ApiResponse({ status: 400, description: '잘못된 요청' }) - async updateSpace(@Param('id') id: string) { - const result = await this.spaceService.existsById(id); + async updateSpaceByName( + @Param('id') id: string, + @Body() updateSpaceDto: UpdateSpaceDto, + ) { + const result = await this.spaceService.updateById(id, updateSpaceDto); if (!result) { this.logger.error('스페이스 업데이트 실패 - 스페이스를 찾을 수 없음', { @@ -158,6 +162,7 @@ export class SpaceController { ); } } + @Version('1') @Delete('/:id') @ApiOperation({ summary: '스페이스 삭제' })