Skip to content

Commit

Permalink
feat: space update 로직 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
fru1tworld committed Dec 3, 2024
1 parent 2d505dc commit 6ab9366
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 24 deletions.
22 changes: 0 additions & 22 deletions packages/backend/src/space/space.controller.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});
});
});
9 changes: 7 additions & 2 deletions packages/backend/src/space/space.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down Expand Up @@ -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('스페이스 업데이트 실패 - 스페이스를 찾을 수 없음', {
Expand All @@ -158,6 +162,7 @@ export class SpaceController {
);
}
}

@Version('1')
@Delete('/:id')
@ApiOperation({ summary: '스페이스 삭제' })
Expand Down

0 comments on commit 6ab9366

Please sign in to comment.