Skip to content

Commit

Permalink
feat: 특정 여행 상세 삭제 컨트롤러 구현
Browse files Browse the repository at this point in the history
  • Loading branch information
Ho-Tea committed Jul 25, 2024
1 parent 3205f21 commit d5edc1b
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

import org.springframework.http.ResponseEntity;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
Expand Down Expand Up @@ -51,4 +52,12 @@ public ResponseEntity<Void> updateTravel(
travelService.updateTravel(travelRequest, travelId);
return ResponseEntity.ok().build();
}

@DeleteMapping("/{travelId}")
public ResponseEntity<Void> deleteTravel(
@PathVariable @Min(value = 1L, message = "여행 식별자는 양수로 이루어져야 합니다.") Long travelId,
@MemberId Long memberId) {
travelService.deleteTravel(travelId);
return ResponseEntity.ok().build();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.DynamicTest;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.TestFactory;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.Arguments;
Expand Down Expand Up @@ -226,4 +227,21 @@ private TravelRequest createTravelRequest(int year) {
LocalDate.of(year, 7, 1),
LocalDate.of(year, 7, 10));
}

@DisplayName("사용자가 여행 상세 삭제를 요청하면, 여행 상세를 삭제한다.")
@Test
void deleteTravel() {
// given
Long travelId = 1L;
TravelRequest travelRequest = new TravelRequest("https://example.com/travels/geumohrm.jpg", "2023 여름 휴가", "친구들과 함께한 여름 휴가 여행", LocalDate.of(2023, 7, 1), LocalDate.of(2023, 7, 10));
createTravel(travelRequest);

// when & then
RestAssured.given().pathParam("travelId", travelId).log().all()
.header(HttpHeaders.AUTHORIZATION, USER_AUTHORIZATION)
.contentType(ContentType.JSON)
.when().delete("/travels/{travelId}")
.then().log().all()
.assertThat().statusCode(HttpStatus.OK.value());
}
}

0 comments on commit d5edc1b

Please sign in to comment.