Skip to content

test: 업로드 관련 통합 테스트 작성#408

Merged
dh2906 merged 4 commits intodevelopfrom
test/406-upload-api-integration-test
Mar 18, 2026
Merged

test: 업로드 관련 통합 테스트 작성#408
dh2906 merged 4 commits intodevelopfrom
test/406-upload-api-integration-test

Conversation

@dh2906
Copy link
Contributor

@dh2906 dh2906 commented Mar 18, 2026

🔍 개요


🚀 주요 변경 내용


💬 참고 사항


✅ Checklist (완료 조건)

  • 코드 스타일 가이드 준수
  • 테스트 코드 포함됨
  • Reviewers / Assignees / Labels 지정 완료
  • 보안 및 민감 정보 검증 (API 키, 환경 변수, 개인정보 등)

@dh2906 dh2906 self-assigned this Mar 18, 2026
@dh2906 dh2906 added the 테스트 테스트 코드 관련 이슈입니다. label Mar 18, 2026
@coderabbitai
Copy link

coderabbitai bot commented Mar 18, 2026

Warning

Rate limit exceeded

@dh2906 has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 11 minutes and 6 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: 24984e8a-2f0b-4d74-bbbb-2628d779aeed

📥 Commits

Reviewing files that changed from the base of the PR and between 9402708 and 6caff1e.

📒 Files selected for processing (1)
  • src/test/java/gg/agit/konect/integration/domain/upload/UploadApiTest.java
📝 Walkthrough

개요

이미지 업로드 엔드포인트에 대한 통합 테스트 클래스를 추가했습니다. S3Client를 모킹하여 정상 업로드, 빈 파일, 지원되지 않는 파일 형식, 파일 크기 초과, S3 실패 등 다양한 시나리오를 검증합니다.

변경 사항

코호트 / 파일 요약
통합 테스트 추가
src/test/java/gg/agit/konect/integration/domain/upload/UploadApiTest.java
이미지 업로드 API의 통합 테스트 클래스 신규 작성. S3 모킹을 통해 정상 업로드(webp 변환, CDN URL 반환), 빈 파일 거부(400 INVALID_REQUEST_BODY), 지원되지 않는 콘텐츠 타입 거부(400 INVALID_FILE_CONTENT_TYPE), 파일 크기 초과 거부(400 INVALID_FILE_SIZE), S3 실패 처리(500 FAILED_UPLOAD_FILE) 등 5가지 시나리오 검증. 헬퍼 메서드로 PNG 바이트 생성, MockMultipartFile 인스턴스 생성, /upload/image 멀티파트 요청 수행.

예상 코드 리뷰 소요 시간

🎯 2 (Simple) | ⏱️ ~10 분

🐰 업로드 테스트 완성했네,
S3는 mock으로 속이고,
빈 파일, 형식, 크기 다 잡았지,
webp로 변환되고 CDN 안겨주고,
에러도 척척 반환하는 우리 API! 🚀

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed PR 제목이 주요 변경 내용인 업로드 API 통합 테스트 작성을 명확하게 설명합니다.
Description check ✅ Passed PR 설명이 관련 이슈 #406을 언급하여 변경 사항과 연관성을 보여줍니다.
Linked Issues check ✅ Passed PR이 이슈 #406의 모든 주요 테스트 시나리오를 구현했습니다: 정상 업로드, 파일 검증 실패, S3 실패 처리, 타깃별 key/URL 생성 규칙 검증.
Out of Scope Changes check ✅ Passed PR의 모든 변경 사항(UploadApiTest 통합 테스트 추가)이 이슈 #406의 요구 사항 범위 내에 있습니다.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch test/406-upload-api-integration-test
📝 Coding Plan
  • Generate coding plan for human review comments

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@src/test/java/gg/agit/konect/integration/domain/upload/UploadApiTest.java`:
- Around line 126-139: Add a new test mirroring
uploadImageWhenS3FailsReturnsInternalServerError that stubs s3Client.putObject
to throw an SdkClientException and asserts the same 500 response and JSON code
"FAILED_UPLOAD_FILE"; specifically, create a test method (e.g.,
uploadImageWhenS3ClientFailsReturnsInternalServerError) using MockMultipartFile
from imageFile(...), willThrow(SdkClientException.builder()...)
.given(s3Client).putObject(any(PutObjectRequest.class), any(RequestBody.class)),
then call uploadImage(file, UploadTarget.CLUB) and expect
status().isInternalServerError() and
jsonPath("$.code").value("FAILED_UPLOAD_FILE") to verify UploadService handles
SdkClientException the same as S3Exception.
- Around line 38-39: Replace the hardcoded MAX_UPLOAD_BYTES constant with the
actual test configuration value: fetch s3StorageProperties.maxUploadBytes() (or
inject the configured property via `@Value` or TestPropertySource) and use that
value in the tests (or add an assertion that MAX_UPLOAD_BYTES equals
s3StorageProperties.maxUploadBytes() if you must keep the constant); update
references to MAX_UPLOAD_BYTES in UploadApiTest to use the injected property or
the assertion so the test stays in sync with configuration (refer to the
MAX_UPLOAD_BYTES constant and the s3StorageProperties.maxUploadBytes() accessor
to locate where to change).

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: 626644bc-0407-4d32-b7ed-465959da3597

📥 Commits

Reviewing files that changed from the base of the PR and between ad4cf2f and 9402708.

📒 Files selected for processing (1)
  • src/test/java/gg/agit/konect/integration/domain/upload/UploadApiTest.java
📜 Review details
🧰 Additional context used
📓 Path-based instructions (1)
**/*

⚙️ CodeRabbit configuration file

**/*: 공통 리뷰 톤 가이드:

  • 모든 코멘트는 첫 줄에 [LEVEL: ...] 태그를 포함한다.
  • 과장된 표현 없이 사실 기반으로 작성한다.
  • 한 코멘트에는 하나의 이슈만 다룬다.
  • 코드 예시가 필요하면 최소 수정 예시를 제시한다.
  • 가독성/단순화/확장성 이슈를 발견하면 우선순위를 높여 코멘트한다.

Files:

  • src/test/java/gg/agit/konect/integration/domain/upload/UploadApiTest.java
🔇 Additional comments (4)
src/test/java/gg/agit/konect/integration/domain/upload/UploadApiTest.java (4)

1-35: [LEVEL: approve] import 구성이 깔끔합니다.

테스트에 필요한 의존성들이 적절히 import 되어 있으며, static import를 활용하여 테스트 코드 가독성을 높였습니다.


53-78: [LEVEL: approve] 성공 케이스 테스트가 잘 작성되었습니다.

  • S3 호출 인자 검증에 ArgumentCaptor 활용이 적절합니다.
  • key 패턴(test/club/...webp)과 CDN URL 검증이 UploadService.buildKey() 로직과 일치합니다.
  • Given/When/Then 패턴이 명확합니다.

80-124: [LEVEL: approve] 검증 실패 케이스들이 적절하게 테스트되었습니다.

  • 빈 파일, 잘못된 content type, 크기 초과 케이스 모두 커버됩니다.
  • verify(s3Client, never())로 검증 실패 시 S3 호출이 없음을 확인하는 것이 좋습니다.
  • 에러 코드가 ApiResponseCode 정의와 일치합니다.

142-160: [LEVEL: approve] 헬퍼 메서드가 잘 구성되었습니다.

  • createPngBytes에서 try-with-resources 패턴을 올바르게 사용했습니다.
  • 테스트 가독성을 높이는 적절한 추상화입니다.

@dh2906 dh2906 merged commit b4e4067 into develop Mar 18, 2026
3 checks passed
@dh2906 dh2906 deleted the test/406-upload-api-integration-test branch March 18, 2026 12:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

테스트 테스트 코드 관련 이슈입니다.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

업로드 관련 통합 테스트 작성

1 participant