a-happy-dev-day / yanawa-server

Rival Matching Services Server
0 stars 1 forks source link

Fix time-issue : 시간 문제 해결 #27

Closed wjdxor closed 1 year ago

wjdxor commented 1 year ago

26 매칭 생성시 자정이 넘어가는 시간대에 생기는 문제

wjdxor commented 1 year ago

입력이 다음날로 안된다는 것을 가정하고 테스트에 조건을 주는 방법으로 수정하였습니다.

this-is-spear commented 1 year ago

@wjdxor 이 문제 자체가 서비스 안의 now() 메서드에 의해 결정이 되는 상황이니 이런 방법은 어떨까요?

  1. now() 메서드를 Mocking
  2. Clock 클래스를 이용한 가짜 객체 생성
wjdxor commented 1 year ago

LocalTime.now(Clock clock)을 호출할때 Clock객체를 mocking할 것이다.

  1. Clock 클래스를 만들어 Clock을 고정해주는 역할을 한다.
  2. MatchingService에서 LocalTime.now()대신 Clock을 주입한다.
  3. Test에서 clock을 통해 시간을 설정한다.

[참고] https://perfectacle.github.io/2018/03/30/mock-time-with-time-machine/

sonarcloud[bot] commented 1 year ago

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 1 Code Smell

92.9% 92.9% Coverage
0.0% 0.0% Duplication