From cba783425422bc5d275c032488a9ed060f409c45 Mon Sep 17 00:00:00 2001 From: Ethan Date: Mon, 20 May 2024 19:14:57 +0900 Subject: [PATCH] CI Test (#8) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * test: 실패하는 테스트 수정 * docs: ci 수정 * docs: ci 수정 * refactor: CI 수정 * refactor: CI 수정 --- .github/workflows/pull-request-open.yml | 59 +++++++++---------- .../macbook/service/MacbookServiceTest.kt | 39 +++++++----- 2 files changed, 52 insertions(+), 46 deletions(-) diff --git a/.github/workflows/pull-request-open.yml b/.github/workflows/pull-request-open.yml index 499ec80..5061101 100644 --- a/.github/workflows/pull-request-open.yml +++ b/.github/workflows/pull-request-open.yml @@ -1,38 +1,37 @@ name: Pull Request Open - on: pull_request: - branches: [ "dev" ] - -permissions: write-all - + branches: ["dev"] jobs: build: runs-on: ubuntu-22.04 + + permissions: write-all steps: - - uses: actions/checkout@v4 - - name: Set up JDK 17 - uses: actions/setup-java@v4 - with: - java-version: '17' - distribution: 'corretto' - - - name: Run tests - run: ./gradlew test - - - name: Build with Gradle - run: ./gradlew build - - - name: Publish Test Result - uses: EnricoMi/publish-unit-test-result-action@v1 - if: always() - with: - files: '**/build/test-results/test/TEST-*.xml' - - - name: Comment Fail Test - uses: mikepenz/action-junit-report@v3 - if: always() - with: - report_paths: '**/build/test-results/test/TEST-*.xml' - token: ${{ github.token }} + - uses: actions/checkout@v4 + + - name: Set up JDK 17 + uses: actions/setup-java@v4 + with: + java-version: "17" + distribution: "corretto" + + - name: Run tests + run: ./gradlew test + + - name: Build with Gradle + run: ./gradlew build + + - name: Publish Test Result + uses: EnricoMi/publish-unit-test-result-action@v1 + if: always() + with: + files: "**/build/test-results/test/TEST-*.xml" + + - name: Comment Fail Test + uses: mikepenz/action-junit-report@v3 + if: always() + with: + report_paths: "**/build/test-results/test/TEST-*.xml" + token: ${{ github.token }} diff --git a/src/test/kotlin/backend/itracker/crawl/macbook/service/MacbookServiceTest.kt b/src/test/kotlin/backend/itracker/crawl/macbook/service/MacbookServiceTest.kt index 52356b9..f806561 100644 --- a/src/test/kotlin/backend/itracker/crawl/macbook/service/MacbookServiceTest.kt +++ b/src/test/kotlin/backend/itracker/crawl/macbook/service/MacbookServiceTest.kt @@ -5,28 +5,13 @@ import backend.itracker.crawl.macbook.domain.MacbookPrice import backend.itracker.crawl.macbook.domain.MacbookRepository import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Assertions.assertAll +import org.junit.jupiter.api.BeforeEach import org.junit.jupiter.api.Test import org.springframework.beans.factory.annotation.Autowired import org.springframework.boot.test.context.SpringBootTest import java.math.BigDecimal import java.time.LocalDateTime -private val macbook = Macbook( - company = "Apple", - name = "Apple 2024 맥북 에어 13 M3, 미드나이트, M3 8코어, 10코어 GPU, 1TB, 16GB, 35W 듀얼, 한글", - type = "맥북 에어", - cpu = "M3 8코어", - gpu = "10코어 GPU", - storage = "1TB", - memory = "16GB", - language = "한글", - color = "미드나이트", - size = 13, - releaseYear = 2024, - productLink = "https://www.coupang.com/vp/products/7975088162?itemId=22505523317&vendorItemId=89547640201&sourceType=cmgoms&omsPageId=84871&omsPageUrl=84871", - thumbnail = "https://thumbnail10.coupangcdn.com/thumbnails/remote/230x230ex/image/retail/images/15943638430632-244768e7-86d1-4484-b772-013d185666b8.jpg", - isOutOfStock = false -) @SpringBootTest class MacbookServiceTest { @@ -37,6 +22,28 @@ class MacbookServiceTest { @Autowired lateinit var macbookRepository: MacbookRepository + private lateinit var macbook: Macbook + + @BeforeEach + fun setUp() { + macbook = Macbook( + company = "Apple", + name = "Apple 2024 맥북 에어 13 M3, 미드나이트, M3 8코어, 10코어 GPU, 1TB, 16GB, 35W 듀얼, 한글", + type = "맥북 에어", + cpu = "M3 8코어", + gpu = "10코어 GPU", + storage = "1TB", + memory = "16GB", + language = "한글", + color = "미드나이트", + size = 13, + releaseYear = 2024, + productLink = "https://www.coupang.com/vp/products/7975088162?itemId=22505523317&vendorItemId=89547640201&sourceType=cmgoms&omsPageId=84871&omsPageUrl=84871", + thumbnail = "https://thumbnail10.coupangcdn.com/thumbnails/remote/230x230ex/image/retail/images/15943638430632-244768e7-86d1-4484-b772-013d185666b8.jpg", + isOutOfStock = false + ) + } + @Test fun `전체 저장 테스트`() { // given