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

주문 단위테스트 구현 #28

Merged
merged 12 commits into from
Sep 6, 2024
Merged

주문 단위테스트 구현 #28

merged 12 commits into from
Sep 6, 2024

Conversation

axhtl
Copy link
Contributor

@axhtl axhtl commented Aug 17, 2024

단위 테스트를 구현하였습니다.

OrderSeller

  • 판매자 주문 리스트 조회
  • 판매자 주문 승인
  • 판매자 주문 취소

OrderUser

  • 단일 주문 조회
  • 전체 주문 조회 offset 방식
  • 전체 주문 조회 slice 방식
  • 주문 저장
  • 주문상세 추가
  • 구매자 구매 확정
  • 구매자 주문 취소
  • 주문 삭제

Copy link

@upswp upswp left a comment

Choose a reason for hiding this comment

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

이 부분 한번 수정부탁드립니다!

Comment on lines +100 to +144
every { orderRepository.findConfirmedAndNotDeletedOrders() } returns listOf(order)
every { order.memberId } returns memberId
every { order.addressId } returns addressId
every { memberService.getMemberByMemberId(memberId) } returns member
every { addressService.getAddressById(addressId) } returns address
every { sellerService.getSellerById(memberId) } returns seller

every { totalPrice.shipping } returns 3000
every { totalPrice.products } returns 5000
every { totalPrice.payment } returns 8000
every { order.orderId } returns orderId
every { member.name } returns "수빈"
every { order.createdAt } returns LocalDateTime.now()
every { order.status } returns Status.CONFIRMED
every { order.paymentMethod } returns PaymentMethod.CARD
every { order.totalPrice } returns totalPrice
every { address.addressInfo } returns addressInfo
every { address.receiverName } returns "수빈"
every { addressInfo.addressBasic } returns "address1"
every { addressInfo.addressDetail } returns "address2"
every { address.telNo } returns "010-1111-1111"
every { address.deliveryRequest } returns "문앞"

val expectedorderResponse = OrderResponse.from(order, member, address)
every { order.orderDetails } returns mutableListOf(orderDetail)
every { orderDetail.deletedAt } returns null

// productIds, itemIds로부터 Product/Item 리스트 가져오기
every { orderDetail.itemId } returns itemId
every { orderDetail.productId } returns productId
every { productService.findByProductIdIn(listOf(productId)) } returns listOf(product)
every { itemService.findByIdIn(listOf(itemId)) } returns listOf(item)

every { item.itemId } returns itemId
every { product.productId } returns productId

every { orderDetail.orderDetailId } returns 1L
every { product.name } returns "상품이름"
every { item.name } returns "상품옵션이름"
every { seller.brandName } returns "brandName"
every { product.price } returns 1000
every { orderDetail.quantity } returns 1
every { orderDetail.price } returns price
every { item.finalPrice } returns 10000
every { price.oneKindTotalPrice } returns 10000
Copy link

Choose a reason for hiding this comment

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

mockk를 사용하면서 테스트하고자 하는 범위를 좁히시면 좋겠습니다.

mockk<Order>(){
   every { order.name } returnThan? = "000"

@axhtl axhtl merged commit 8c82be5 into develop Sep 6, 2024
6 checks passed
@axhtl axhtl deleted the test/order-unit branch September 6, 2024 18:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants