Skip to content

Commit

Permalink
test4
Browse files Browse the repository at this point in the history
  • Loading branch information
zzzzseong committed Feb 2, 2024
1 parent 6242a25 commit e71fced
Showing 1 changed file with 18 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -75,19 +75,25 @@ void tearDown() {
@DisplayName("단일 구매자의 구매 테스트")
class SinglePurchaseTest {

private Product product;
private Hotdeal hotdeal;

private PurchaseHotdealRequestDto requestDto;

@BeforeEach
void setUp() {
product = productRepository.save(ANOTHER_TEST_PRODUCT);
hotdeal = hotdealRepository.save(
HotdealTestUtil.createHotdeal(TEST_START_DAY, TEST_DUE_DAY, TEST_DEAL_QUANTITY,
TEST_SALE, product));
requestDto = HotdealTestUtil.createTestPurchaseHotdealRequestDto(hotdeal.getId(), 3);
}

@AfterEach
void tearDown() {
purchaseRepository.deleteAll();
}

private Product product = productRepository.save(ANOTHER_TEST_PRODUCT);
private Hotdeal hotdeal = hotdealRepository.save(
HotdealTestUtil.createHotdeal(TEST_START_DAY, TEST_DUE_DAY, TEST_DEAL_QUANTITY,
TEST_SALE, product));

private PurchaseHotdealRequestDto requestDto = HotdealTestUtil.createTestPurchaseHotdealRequestDto(
hotdeal.getId(), 3);

@Test
@DisplayName("성공 - 구매자가 구매한 상품이 구매 목록에 추가되는지 확인")
void purchaseHotdeal() {
Expand All @@ -105,10 +111,10 @@ void purchaseHotdeal_decreaseDealQuantity() {
hotdealService.purchaseHotdeal(member, requestDto);

// then
// Hotdeal foundHotdeal = hotdealRepository.findById(hotdeal.getId())
// .orElseThrow(() -> new AssertionError("핫딜을 찾을 수 없음"));
// assertEquals(beforeDealQuantity - requestDto.getQuantity(),
// foundHotdeal.getDealQuantity());
Hotdeal foundHotdeal = hotdealRepository.findById(hotdeal.getId())
.orElseThrow(() -> new AssertionError("핫딜을 찾을 수 없음"));
assertEquals(beforeDealQuantity - requestDto.getQuantity(),
foundHotdeal.getDealQuantity());
}

@Test
Expand Down

0 comments on commit e71fced

Please sign in to comment.