Repository navigation
Conversation
// given 블록 안에 when( 이 와서 같은 단어가 반대 뜻으로 쓰이는 충돌을 없애기 위해 classic Mockito 를 BDDMockito 로 전환한다. 16개 파일, 동작 변경 없음 (476개 통과 유지). - when().thenReturn() -> given().willReturn() - when().thenThrow() -> given().willThrow() - doThrow().when() -> willThrow().given() - verify() -> then().should() - verify(m, never()) -> then(m).should(never()) - verifyNoInteractions() -> then().shouldHaveNoInteractions() - order.verify() -> then().should(order) lenient().when() 과 order.verifyNoMoreInteractions() 는 BDDMockito 에 대응 API 가 없어 classic 을 유지한다.
테스트 카테고리 7종 규칙을 기존 코드에 적용한 결과다. model 이 컬럼 폭(VARCHAR(80))을 넘어도 검증을 통과해 네이티브 INSERT 까지 내려가 500 이 났고, @transactional 이라 그 sync 배치 전체가 롤백됐다. 토큰 필드는 상한이 없어 집계 SUM 에서 bigint 오버플로가 가능했다. - TokenRecordRequest: model @SiZe(80), 토큰 4필드 @max(1e11) - SyncRequest: records @SiZe(10000) - SyncSchemaConstraintTest(신규): 제약값과 DDL 을 대조 - SyncControllerTest(신규): @Valid -> 400, 미인증 -> 401 배선 검증 - CardClaudeBadgeThemeTest: 레벨 임계 직전/직후 9케이스 추가 - 세터 왕복, 복합키 중복 등 회귀 신호 없는 테스트 8건 제거 유닛 493, 통합 37 통과.
refactor: 유닛테스트를 BDDMockito로 포팅
fix: sync 입력 제약 보강 및 회귀 신호 없는 테스트 정리
미가입 username은 이제 모든 테마에서 404 BADGE_001을 받는다. 가입했지만 자격이 없는 경우는 기존대로 200 잠금 SVG다. 기존에는 자격이 필요한 테마(beta-tester)만 200 잠금 SVG를 반환했다. 자격 게이트가 사용자 조회보다 먼저 걸려 오타 username이 걸러지지 않았다. findGrant 쿼리에 userExists 컬럼을 더해 DB 왕복을 늘리지 않고 판별하며, BadgeRenderService가 자격 분기보다 앞에서 BADGE_001을 던진다.
/badge/ 같은 라우팅 미스는 404 NOT_FOUND를, POST /badge/{username} 은
405 METHOD_NOT_ALLOWED를 반환한다. ERROR 스택트레이스도 남지 않는다.
기존에는 GlobalExceptionHandler의 catch-all이 Spring MVC 표준 예외까지
삼켜 전부 500 SERVER_ERROR로 나갔다. /badge/** 가 permitAll이라
미인증 요청만으로 ERROR 로그를 쌓을 수 있었다.
ErrorResponse를 구현하는 예외 5종을 전용 핸들러로 잡고, 응답 코드와
메시지를 예외가 지정한 상태에서 파생해 매핑 표 없이 처리한다.
fix: 배지 조회 응답 상태코드 정정 — 미가입 404 통일 및 라우팅 미스 4xx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
🏷️ 작업 유형
📋 변경 사항
요약
26.08.26유지 — 직전 docs: 배지 예시를 붙여쓸 수 있는 마크다운 스니펫으로 교체 #14·feat: beta-tester 배지 추가와 mode 축 enum 개조 #16·#18도 변경 없음배포 시 주의
BADGES.md:209locked 배지 예시 이미지 깨짐octocat?theme=beta-tester,octocat은 미가입 계정1. 미가입 사용자 배지 응답 404 통일 (
cc71356, #21)?theme=beta-testerBADGE_001?theme=gpuBADGE_001?theme=beta-testerfindGrant쿼리에userExists컬럼 추가, DB 왕복 증가 없음BadgeRenderService가 자격 분기 앞에서BADGE_001throw2. 라우팅 미스 4xx 반환 (
193b976, #21)GET /badge/,/badge,/badge/{u}/SERVER_ERRORNOT_FOUNDPOST /badge/{u}SERVER_ERRORMETHOD_NOT_ALLOWEDGlobalExceptionHandler의@ExceptionHandler(Exception.class)가 Spring MVC 표준 예외까지 포획/badge/**가permitAll이라 미인증 요청만으로 ERROR 스택트레이스 축적 가능ErrorResponse구현 예외 5종 전용 핸들러, 응답 코드·메시지를 예외가 지정한 상태에서 파생3. 그 외
33acaf9—.omc/gitignore 추가, 에이전트 하네스 로컬 디렉터리f752d99— sync 입력 제약 보강 및 회귀 신호 없는 테스트 정리 (fix: sync 입력 제약 보강 및 회귀 신호 없는 테스트 정리 #20 검토 완료)c456db0— 유닛테스트 BDDMockito 포팅 (refactor: 유닛테스트를 BDDMockito로 포팅 #19 검토 완료)✅ 테스트
결론 — develop 머지 커밋
c583e55e에서 CI 두 잡 모두 통과./mvnw test./mvnw verifyGlobalExceptionHandlerWebMvcTest— 실제 디스패치를 태워 핸들러 도달 경로 검증UserBadgeGrantRepositoryIntegrationTest— 실 Postgres로userExistsalias ↔ getter 매핑 검증