Skip to content

Commit

Permalink
test: 테스트 수정
Browse files Browse the repository at this point in the history
Co-authored-by: dradnats1012 <herjebi1012@gmail.com>, Choon0414 <hyunn815@naver.com>
  • Loading branch information
Choi-JJunho and Choon0414 committed Apr 4, 2024
1 parent 80bb4a9 commit e5eaa51
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,6 @@ private List<ExpressBusRemainTime> getExpressBusRemainTime(
@Override
public boolean isCacheExpired(Version version, Clock clock) {
Duration duration = Duration.between(version.getUpdatedAt().toLocalTime(), LocalTime.now(clock));
return duration.toSeconds() < 0 || ExpressBusCache.getCacheExpireHour() <= duration.toHours();
return duration.toSeconds() < 0 || Duration.ofHours(ExpressBusCache.getCacheExpireHour()).toSeconds() <= duration.toSeconds();
}
}
17 changes: 12 additions & 5 deletions src/test/java/in/koreatech/koin/acceptance/BusApiTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -317,18 +317,25 @@ void getNextCityBusRemainTimeOpenApi() {
@Test
@DisplayName("다음 시외버스까지 남은 시간을 조회한다. - Redis")
void getNextExpressBusRemainTimeRedis() {
Instant requestedAt = ZonedDateTime.parse("2024-02-21 18:00:30 KST", ofPattern("yyyy-MM-dd " + "HH:mm:ss z"))
.toInstant();
when(dateTimeProvider.getNow()).thenReturn(Optional.of(requestedAt));
when(dateTimeProvider.getNow()).thenReturn(Optional.of(UPDATED_AT));

BusType busType = BusType.from("express");
BusStation depart = BusStation.from("terminal");
BusStation arrival = BusStation.from("koreatech");

Version version = versionRepository.save(
Version.builder()
.version("20240_1711255839")
.type(EXPRESS.getValue())
.build()
);
versionRepository.save(version);

Instant requestedAt = ZonedDateTime.parse("2024-02-21 18:00:30 KST", ofPattern("yyyy-MM-dd " + "HH:mm:ss z"))
.toInstant();

when(clock.instant()).thenReturn(requestedAt);
when(dateTimeProvider.getNow()).thenReturn(Optional.of(requestedAt));

expressBusCacheRepository.save(
ExpressBusCache.create(
Expand All @@ -346,8 +353,8 @@ void getNextExpressBusRemainTimeRedis() {
.given()
.when()
.param("bus_type", busType.name().toLowerCase())
.param("depart", depart.name().toLowerCase())
.param("arrival", arrival.name().toLowerCase())
.param("depart", depart.name())
.param("arrival", arrival.name())
.get("/bus")
.then()
.statusCode(HttpStatus.OK.value())
Expand Down

0 comments on commit e5eaa51

Please sign in to comment.