Skip to content

Conversation

@leegwichan
Copy link
Member

@leegwichan leegwichan commented Dec 21, 2025

🚩 연관 이슈

closed #

🗣️ 리뷰 요구사항 (선택)

아래 글을 읽어주세요.

해당 테스트가 Mac에서 통과하는 이유 (by Gemini)

  • Mac(macOS)은 전통적으로 시스템 클럭을 마이크로초(6자리, 0.000001초) 단위로 제공하는 경우가 많습니다.
  • 현재 시간: ...10.123456000 (Mac은 뒤 3자리를 0으로 줌)
  • Java 로직 (minusNanos(1)): ...10.123455999 (9자리로 계산됨)
  • H2 저장 (6자리로 잘림):
    • 원본: ...10.123456
    • 변경: ...10.123455 (마지막 999가 잘려나감)
  • 비교: 123456 vs 123455 -> 다르다! (테스트 통과 ✅)

윈도우에서 해당 테스트가 통과하지 않는 이유 (by Gemini)

  • 최신 Windows는 시스템 클럭을 나노초(9자리, 0.000000001초) 단위까지 꽉 채워서 제공합니다.
  • 현재 시간: ...10.123456789 (9자리 꽉 참)
  • Java 로직 (minusNanos(1)): ...10.123456788
  • H2 저장 (6자리로 잘림):
    • 원본: ...10.123456 (뒤 789 버림)
    • 변경: ...10.123456 (뒤 788 버림)
  • 비교: 123456 vs 123456 -> 같다! (테스트 실패 ❌)

그래서 1초 차이로 테스트에 반영하도록 수정했습니다. 추가적인 리뷰 부탁드립니다.

Summary by CodeRabbit

버그 수정

  • 타임스탠프 초기화 동작 조정 - 엔티티 생성 시 타임스탠프 초기화 방식이 변경되었습니다. 테스트 정확성 개선으로 타임스탠프 검증이 강화되었습니다.

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai
Copy link

coderabbitai bot commented Dec 21, 2025

개요

생성자에서 usedAt 필드 초기화 방식을 LocalDateTime.now()에서 customizeTable.getUsedAt()으로 변경하고, 테스트 케이스의 타임스탬프 정밀도를 나노초에서 초 단위로 조정했습니다.

변경 사항

코호트 / 파일 변경 요약
엔티티 생성자 로직 변경
src/main/java/com/debatetimer/entity/customize/CustomizeTableEntity.java
usedAt 필드 초기화 방식을 customizeTable.getUsedAt()에서 가져오도록 수정. 기존 updateTableupdateUsedAt 로직은 유지됨
테스트 타임스탬프 정밀도 조정
src/test/java/com/debatetimer/entity/customize/CustomizeTableEntityTest.java
두 개의 테스트 케이스에서 createdAt 타임스탐프 생성 방식을 LocalDateTime.now().minusNanos(1L)에서 LocalDateTime.now().minusSeconds(1L)로 변경. 제어 흐름 및 공개 API 변경 없음

예상 코드 리뷰 소요 시간

🎯 2 (단순) | ⏱️ ~10분

  • usedAt 초기화 로직 변경이 다른 생명주기 메서드와의 상호작용에 미치는 영향 확인 필요
  • 타임스탬프 정밀도 변경이 테스트 신뢰성에 미치는 영향 검토

Pre-merge checks and finishing touches

❌ 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%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed PR 제목은 "[Test] 시간 기반 테스트 수정"으로, 테스트 코드의 시간 관련 로직을 수정했다는 내용을 명확하게 요약하고 있습니다.
Description check ✅ Passed PR 설명은 템플릿의 모든 섹션(연관 이슈, 리뷰 요구사항)을 포함하고 있으며, Windows와 macOS의 시계 정밀도 차이로 인한 테스트 실패 원인을 자세히 설명하고 수정 사항을 명확히 제시합니다.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch test/time-based

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.

@gemini-code-assist
Copy link

Summary of Changes

Hello @leegwichan, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

이 PR은 CustomizeTableEntity의 usedAt 필드 처리 방식을 개선하고, 특히 Mac과 Windows 환경 간의 시간 정밀도 차이로 인해 발생하던 불안정한 테스트를 수정하는 것을 목표로 합니다. usedAt 필드가 생성 시점에 현재 시간으로 자동 설정되는 대신, 외부에서 주입된 값을 사용하도록 변경하여 유연성을 높였습니다. 또한, 테스트에서 시간 비교 로직을 나노초 단위에서 초 단위로 변경하여 플랫폼 독립적인 테스트 결과를 보장합니다.

Highlights

  • CustomizeTableEntity 생성자 변경: CustomizeTableEntity의 생성자에서 usedAt 필드를 LocalDateTime.now() 대신 CustomizeTable 객체로부터 가져오도록 수정했습니다.
  • 시간 기반 테스트 수정: 운영체제별 시간 정밀도 차이로 인해 발생하던 테스트 실패를 해결하기 위해 LocalDateTime.now().minusNanos(1L)을 LocalDateTime.now().minusSeconds(1L)로 변경했습니다.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

이 PR은 서로 다른 운영 체제에서 LocalDateTime의 정밀도 차이로 인해 발생하던 시간 기반 테스트의 불안정성 문제를 해결합니다. CustomizeTableEntity 생성자에서 usedAt 필드를 도메인 객체의 값을 사용하도록 수정한 것은 올바른 버그 수정입니다. 또한, 테스트 코드에서 minusNanos(1L)minusSeconds(1L)로 변경하여 시간 비교가 정밀도 문제에 영향을 받지 않도록 개선한 점도 좋습니다. 다만, 테스트의 안정성을 더욱 높이기 위해 몇 가지 제안 사항을 코멘트로 남겼습니다. 전반적으로 좋은 수정이라고 생각합니다.

Member member = new Member("default@gmail.com");
CustomizeTable table = new CustomizeTable(member, "tableName", "agenda", "찬성", "반대",
true, true, LocalDateTime.now().minusNanos(1L));
true, true, LocalDateTime.now().minusSeconds(1L));

Choose a reason for hiding this comment

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

medium

minusSeconds(1L)로 변경하여 시간 정밀도 문제를 해결한 것은 좋은 접근입니다. 다만, 테스트 코드에서 LocalDateTime.now()를 직접 사용하면 테스트가 실행되는 환경이나 시점에 따라 예상치 못하게 실패할 수 있는 비결정적 테스트(flaky test)가 될 수 있습니다. 보다 견고한 테스트를 위해 Clock을 주입하여 시간을 고정하거나, LocalDateTime.of()를 사용하여 특정 시간 값을 명시적으로 사용하는 것을 고려해 보시는 것이 좋습니다.

Member member = new Member("default@gmail.com");
CustomizeTable table = new CustomizeTable(member, "tableName", "agenda", "찬성", "반대",
true, true, LocalDateTime.now().minusNanos(1L));
true, true, LocalDateTime.now().minusSeconds(1L));

Choose a reason for hiding this comment

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

medium

이 테스트 케이스도 마찬가지로 LocalDateTime.now()를 사용하고 있어 비결정적일 수 있습니다. 테스트의 신뢰도를 높이기 위해 Clock을 사용해 시간을 제어하는 방식을 적용하는 것을 추천합니다. 이렇게 하면 updateTable 메소드 내의 LocalDateTime.now() 호출까지 제어할 수 있어 더욱 안정적인 테스트가 가능해집니다.

@github-actions
Copy link

Test Results

135 files  135 suites   14s ⏱️
285 tests 285 ✅ 0 💤 0 ❌
297 runs  297 ✅ 0 💤 0 ❌

Results for commit cfa2c2c.

@github-actions
Copy link

📝 Test Coverage Report

Overall Project 88.7% 🍏
Files changed 100% 🍏

File Coverage
CustomizeTableEntity.java 100% 🍏

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: 0

🧹 Nitpick comments (1)
src/test/java/com/debatetimer/entity/customize/CustomizeTableEntityTest.java (1)

50-50: 일관성을 위해 minusSeconds(1L) 사용을 권장합니다.

이 테스트는 usedAt을 검증하지 않지만, 33번과 71번 라인과의 일관성을 위해 minusSeconds(1L)로 변경하는 것이 코드베이스 전체의 통일성을 높일 수 있습니다.

🔎 일관성을 위한 제안
         CustomizeTable table = new CustomizeTable(member, "tableName", "agenda", "찬성", "반대",
-                true, true, LocalDateTime.now().minusNanos(1L));
+                true, true, LocalDateTime.now().minusSeconds(1L));
📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 3bd25cf and cfa2c2c.

📒 Files selected for processing (2)
  • src/main/java/com/debatetimer/entity/customize/CustomizeTableEntity.java (1 hunks)
  • src/test/java/com/debatetimer/entity/customize/CustomizeTableEntityTest.java (2 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: build-and-push
🔇 Additional comments (2)
src/test/java/com/debatetimer/entity/customize/CustomizeTableEntityTest.java (1)

33-33: 크로스 플랫폼 타임스탬프 정밀도 문제 해결을 승인합니다.

minusNanos(1L)에서 minusSeconds(1L)로 변경하여 H2의 마이크로초(6자리) 정밀도 절단으로 인한 플랫폼 간 테스트 불일치 문제를 해결했습니다. 1초 차이는 isAfter 단언문이 모든 플랫폼에서 일관되게 통과하기에 충분합니다.

Also applies to: 71-71

src/main/java/com/debatetimer/entity/customize/CustomizeTableEntity.java (1)

63-63: 이 변경은 테스트를 위해 의도적으로 설계되었으며 프로덕션 환경에서는 안전합니다.

CustomizeTable 인스턴스는 요청 처리 시점에 LocalDateTime.now()로 생성되며, 같은 트랜잭션 내에서 즉시 엔티티로 영속화됩니다. CustomizeTable 생성과 엔티티 저장 사이의 시간 차이는 무시할 수 있는 수준입니다. 이 변경으로 테스트에서 타임스탬프를 제어할 수 있게 되었으며, updateTable()updateUsedAt() 메서드의 동작을 검증하는 테스트가 정상적으로 작동합니다.

Likely an incorrect or invalid review comment.

Copy link
Contributor

@coli-geonwoo coli-geonwoo left a comment

Choose a reason for hiding this comment

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

/noti

커찬, 흥미로운 이슈를 해결하셨네요 :) approve 합니다~

this.warningBell = customizeTable.isWarningBell();
this.finishBell = customizeTable.isFinishBell();
this.usedAt = LocalDateTime.now();
this.usedAt = customizeTable.getUsedAt();
Copy link
Contributor

Choose a reason for hiding this comment

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

이건 한번 영속화되었던 거니까 아무래도 벤더와 무관하게 나노초 범위를 똑같이 통일시켜준거군요 👍

Copy link
Member Author

Choose a reason for hiding this comment

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

테스트도 1초 뒤로 설정해서, DB와 무관하게 테스트를 통과하도록 수정했습니다~

Copy link
Contributor

@unifolio0 unifolio0 left a comment

Choose a reason for hiding this comment

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

/noti
approve합니다

@leegwichan leegwichan merged commit 4c0045b into develop Dec 22, 2025
9 of 10 checks passed
@leegwichan leegwichan deleted the test/time-based branch December 22, 2025 14:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants