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

feature: 배너 이미지 조회 #18

Merged
merged 14 commits into from
Jan 26, 2024

Conversation

TaeyeonRoyce
Copy link
Member

@TaeyeonRoyce TaeyeonRoyce commented Jan 24, 2024

📌 관련 이슈

📁 작업 설명

  • 홈 화면에서 사용 배너 정보를 제공하는 API 개발

  • Spring Cache를 통해 배너 정보 caching

  • 워크플로우 수정

    • CI의 경우 push하는 경우에만 수행되도록 변경하였습니다. 보통 push -> PR을 생성하니깐 동일한 작업이 2번 돌더라고요.
    • CD의 경우 docker image가 삭제 되지 않는 현상이 발견되어서 image를 지우는 option을 추가하였습니다.
    • 배포시 table이 생성되어 있지 않아 임시로 ddl-auto: create를 추가하였습니다.

💻 미완료 태스크

  • BaseEntity 적용
  • API Test

기타

ApiTestConfig를 추가했습니다! 7c74c6b

공통으로 설정되는 부분들 (`@SpringBootTest(web ..), dataCleaner, afterContainer)을 공통화 해보았습니다.
BehaviorSpec을 상속하는 구조이다 보니, 추가하기 어려웠는데요. 달라진 점은 아래와 같습니다!

AS-IS

@SpringBootTest(webEnvironment = RANDOM_PORT)
class BannerControllerTest(
    @LocalServerPort private val port: Int,
    private val bannerRepository: BannerRepository,
    private val dataCleaner: DataCleaner,
) : BehaviorSpec({

    RestAssured.port = port

    Given() {
//  ....
    }

    afterContainer {
        dataCleaner.clean()
    }
)}

TO-BE

class BannerControllerTest(
    private val bannerRepository: BannerRepository
) : ApiTestConfig() {

    init {
        Given() {
        // ....
       }
   }
}

ApiTestConfig에서 BehaviorSpec을 상속해서 init{} depth가 생겼는데요.
다들 어떠신가요? 의견에 따라 반영해보겠습니다.
쉽게 롤백하기 위해 커밋을 분리해두었어요!

Copy link

github-actions bot commented Jan 24, 2024

Test Results

 7 files  +2   7 suites  +2   2s ⏱️ ±0s
21 tests +3  21 ✅ +3  0 💤 ±0  0 ❌ ±0 
23 runs  +3  23 ✅ +3  0 💤 ±0  0 ❌ ±0 

Results for commit 18ffcc5. ± Comparison against base commit c98a990.

♻️ This comment has been updated with latest results.

@TaeyeonRoyce TaeyeonRoyce force-pushed the 16-feature-배너-이미지-조회 branch from 8567d37 to bec1f0b Compare January 26, 2024 05:19
@TaeyeonRoyce TaeyeonRoyce marked this pull request as ready for review January 26, 2024 05:22
Copy link
Contributor

@hgo641 hgo641 left a comment

Choose a reason for hiding this comment

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

어쁘루브합니다 ApiTestConfig 넘 좋네요 고생하셨습니닷


@GetMapping
fun readAll(): ResponseEntity<List<BannerResponse>> {
val bannerList = bannerService.readAll()
Copy link
Contributor

Choose a reason for hiding this comment

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

오 변수명에 자료형 이름 쓰는 거 허용하시나요
전 좋긴함.

Copy link
Member Author

Choose a reason for hiding this comment

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

안쓰는게 좋을 것 같아요!
수정하겠습니다~

import org.springframework.boot.test.web.server.LocalServerPort

@SpringBootTest(webEnvironment = RANDOM_PORT)
abstract class ApiTestConfig : BehaviorSpec() {
Copy link
Contributor

Choose a reason for hiding this comment

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

조아요~~

Copy link
Contributor

@Combi153 Combi153 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 +49 to +50
needs: [ build-docker-image-and-push ]
steps:
Copy link
Contributor

Choose a reason for hiding this comment

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

도커 공부 해야하는데 언제하죠ㅋㅋㅋㅎ

Comment on lines 10 to 11
val createAt: LocalDateTime,
val updateAt: LocalDateTime,
Copy link
Contributor

Choose a reason for hiding this comment

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

createAt, updateAt 도 응답하네요! 클라이언트에게 아마도 필요하지 않을 정보를 응답하는 이유가 궁금합니다

Copy link
Member Author

Choose a reason for hiding this comment

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

문제없는 범위 내에서 createdAt을 자주 응답하긴 했었습니다.. 추후에 추가되는 경우가 종종 있었거든요!
굳이 응답할 필요 없는 것 같은데 제거해두겠습니다~!

Comment on lines +13 to +14

@Cacheable("banners")
Copy link
Contributor

Choose a reason for hiding this comment

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

캐시 좋네요! 이거 나중에 레디스로 이사하나요?

Copy link
Member Author

Choose a reason for hiding this comment

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

나중에 cacheConfig에서 구현체만 수정하면 될 것 같군요!
레디스를 생각하진 않았는데, 레디스가 도입되면 얘도 거기서 처리하면 되겠네요

package com.petqua.domain.banner

import com.petqua.common.domain.BaseEntity
import jakarta.persistence.*
Copy link
Contributor

Choose a reason for hiding this comment

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

* 👻 귀신이다아아

Comment on lines 39 to 43
When("Banner가 캐싱 되어 있으면") {
repeat(5) { bannerService.getBannerList() }

Then("퀴리가 발생 하지 않는다") {
verify(bannerRepository, atMost(1)).findAll()
Copy link
Contributor

Choose a reason for hiding this comment

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

꼼꼼 테스트 좋아요 👍

Comment on lines +10 to +24
@SpringBootTest(webEnvironment = RANDOM_PORT)
abstract class ApiTestConfig : BehaviorSpec() {

@LocalServerPort
protected val port: Int = RestAssured.port

@Autowired
private lateinit var dataCleaner: DataCleaner

init {
afterContainer {
dataCleaner.clean()
}
}
}
Copy link
Contributor

Choose a reason for hiding this comment

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

저는 너무 좋은데요! 한결 편해질 것 같아요!!!

Comment on lines 39 to 40
assertThat(response.statusCode).isEqualTo(HttpStatus.OK.value())
assertThat(findBannerResponse.size).isEqualTo(2)
Copy link
Contributor

Choose a reason for hiding this comment

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

SoftAssertions 안 쓰면 홍고가 화내요ㅠ

Copy link
Contributor

Choose a reason for hiding this comment

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

아 이걸 놓쳤네;;;;;;;;;;;

@TaeyeonRoyce TaeyeonRoyce merged commit 69cd895 into develop Jan 26, 2024
2 checks passed
@TaeyeonRoyce TaeyeonRoyce deleted the 16-feature-배너-이미지-조회 branch January 26, 2024 07:54
hgo641 pushed a commit that referenced this pull request Jan 28, 2024
* feat: Banner 도메인 추가

* chore: Spring Cache 설정 추가

* feat: Banner 조회 로직 추가

* feat: Banner 조회 API 추가

* test: Banner Api test 추가

* test: Api test 공통화

* chore: 배포 오류 수정
- ddl-auto option으로 table 생성
- docker compose시 이전 Image 삭제 옵션 추가

* chore: CI scope 수정
- only push

* refactor: Api resource url 수정

* style: method, dto naming 수정

* style: 변수명에 자료형 제거

* refactor: 불필요한 응답 필드 제거

* style: static import 제거

* test: SoftAssertions 적용
hgo641 pushed a commit that referenced this pull request Jan 29, 2024
* feat: Banner 도메인 추가

* chore: Spring Cache 설정 추가

* feat: Banner 조회 로직 추가

* feat: Banner 조회 API 추가

* test: Banner Api test 추가

* test: Api test 공통화

* chore: 배포 오류 수정
- ddl-auto option으로 table 생성
- docker compose시 이전 Image 삭제 옵션 추가

* chore: CI scope 수정
- only push

* refactor: Api resource url 수정

* style: method, dto naming 수정

* style: 변수명에 자료형 제거

* refactor: 불필요한 응답 필드 제거

* style: static import 제거

* test: SoftAssertions 적용
hgo641 pushed a commit that referenced this pull request Jan 29, 2024
* feat: Banner 도메인 추가

* chore: Spring Cache 설정 추가

* feat: Banner 조회 로직 추가

* feat: Banner 조회 API 추가

* test: Banner Api test 추가

* test: Api test 공통화

* chore: 배포 오류 수정
- ddl-auto option으로 table 생성
- docker compose시 이전 Image 삭제 옵션 추가

* chore: CI scope 수정
- only push

* refactor: Api resource url 수정

* style: method, dto naming 수정

* style: 변수명에 자료형 제거

* refactor: 불필요한 응답 필드 제거

* style: static import 제거

* test: SoftAssertions 적용
hgo641 pushed a commit that referenced this pull request Jan 29, 2024
* feat: Banner 도메인 추가

* chore: Spring Cache 설정 추가

* feat: Banner 조회 로직 추가

* feat: Banner 조회 API 추가

* test: Banner Api test 추가

* test: Api test 공통화

* chore: 배포 오류 수정
- ddl-auto option으로 table 생성
- docker compose시 이전 Image 삭제 옵션 추가

* chore: CI scope 수정
- only push

* refactor: Api resource url 수정

* style: method, dto naming 수정

* style: 변수명에 자료형 제거

* refactor: 불필요한 응답 필드 제거

* style: static import 제거

* test: SoftAssertions 적용
hgo641 pushed a commit that referenced this pull request Jan 29, 2024
* feat: Banner 도메인 추가

* chore: Spring Cache 설정 추가

* feat: Banner 조회 로직 추가

* feat: Banner 조회 API 추가

* test: Banner Api test 추가

* test: Api test 공통화

* chore: 배포 오류 수정
- ddl-auto option으로 table 생성
- docker compose시 이전 Image 삭제 옵션 추가

* chore: CI scope 수정
- only push

* refactor: Api resource url 수정

* style: method, dto naming 수정

* style: 변수명에 자료형 제거

* refactor: 불필요한 응답 필드 제거

* style: static import 제거

* test: SoftAssertions 적용
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

feature: 배너 이미지 조회
3 participants