Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BE] 시간에 따라 실패하는 테스트 수정 #539

Open
wants to merge 1 commit into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -209,10 +209,14 @@ void useCoffeeStack() {
final List<Long> userIds = saveUsers(createUsers());
final Meeting meeting = MORAGORA.create();
final int meetingId = saveMeeting(token, userIds, meeting);

final LocalDate date = LocalDate.now();
final Event event = EVENT_WITHOUT_DATE.createEventOnDate(meeting, date);
final LocalTime time = LocalTime.of(10, 0);
final LocalDateTime now = LocalDateTime.of(date, time.plusMinutes(1));
Copy link
Collaborator

Choose a reason for hiding this comment

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

변수명 fakeNow 또는 mockNow처럼 실제 시간이 아닌 가짜 값임을 나타낼 수 있게 rename하는건 어떤가요?

final Event event = EVENT_WITHOUT_DATE.createEventOnDateAndTime(meeting, date, time);

given(serverTimeManager.getDate()).willReturn(date);
given(serverTimeManager.getDateAndTime()).willReturn(now);

saveEvents(token, List.of(event), (long) meetingId);

Expand Down Expand Up @@ -263,13 +267,16 @@ void showUserCoffeeStats() {
final Long masterId = signUp(master);
final String token = login(master);
final LocalDate date = LocalDate.now();
final LocalTime time = LocalTime.of(10, 0);
final LocalDateTime now = LocalDateTime.of(date, time.plusMinutes(1));

final List<Long> userIds = saveUsers(createUsers());
final Meeting meeting = MORAGORA.create();
final int meetingId = saveMeeting(token, userIds, meeting);
final Event event = EVENT_WITHOUT_DATE.createEventOnDate(meeting, date);
final Event event = EVENT_WITHOUT_DATE.createEventOnDateAndTime(meeting, date, time);
Copy link
Collaborator

Choose a reason for hiding this comment

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

createEventOnDateTime 도 괜찮을 것 같아요 :)


given(serverTimeManager.getDate()).willReturn(date);
given(serverTimeManager.getDateAndTime()).willReturn(now);
saveEvents(token, List.of(event), (long) meetingId);

// when
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import com.woowacourse.moragora.dto.request.meeting.MeetingUpdateRequest;
import io.restassured.response.ValidatableResponse;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.LocalTime;
import java.time.format.DateTimeFormatter;
import java.util.List;
Expand Down Expand Up @@ -107,11 +108,15 @@ void findMy() {
final int meetingId2 = saveMeeting(token, ids, meeting2);

final LocalDate today = LocalDate.now();
final Event event = EVENT_WITHOUT_DATE.createEventOnDate(meeting1, today);
final LocalTime time = LocalTime.of(10, 0);
final LocalDateTime now = LocalDateTime.of(today, time.plusMinutes(1));

final Event event = EVENT_WITHOUT_DATE.createEventOnDateAndTime(meeting1, today, time);

given(serverTimeManager.getDate())
.willReturn(event.getDate());
given(serverTimeManager.isAttendanceOpen(LocalTime.of(10, 0)))
given(serverTimeManager.getDateAndTime()).willReturn(now);
given(serverTimeManager.isAttendanceOpen(time))
.willReturn(true);
given(serverTimeManager.calculateOpenTime(event.getStartTime()))
.willReturn(LocalTime.of(9, 30));
Expand Down