pricelees d3e22888ed [#28] 쿠버네티스 환경 배포 (#29)
<!-- 제목 양식 -->
<!-- [이슈번호] 작업 요약 (예시: [#10] Gitea 템플릿 생성) -->

## 📝 관련 이슈 및 PR

**PR과 관련된 이슈 번호**
- #28

##  작업 내용
<!-- 어떤 작업을 했는지 알려주세요! -->
- 프론트엔드, 백엔드 쿠버네티스 환경 배포(ArgoCD 이용)
- Helm 차트는 private repository에 업로드

## 🧪 테스트
<!-- 어떤 테스트를 생각했고 진행했는지 알려주세요! -->
- 배포 환경에서 기능 정상 동작 확인

## 📚 참고 자료 및 기타
<!-- 참고한 자료, 또는 논의할 사항이 있다면 알려주세요! -->

Reviewed-on: #29
Co-authored-by: pricelees <priceelees@gmail.com>
Co-committed-by: pricelees <priceelees@gmail.com>
2025-08-04 05:59:38 +00:00

123 lines
3.8 KiB
Kotlin

package roomescape.theme.business
import io.kotest.assertions.assertSoftly
import io.kotest.assertions.throwables.shouldThrow
import io.kotest.core.spec.style.FunSpec
import io.kotest.matchers.shouldBe
import io.mockk.every
import io.mockk.mockk
import org.springframework.data.repository.findByIdOrNull
import roomescape.theme.exception.ThemeErrorCode
import roomescape.theme.exception.ThemeException
import roomescape.theme.infrastructure.persistence.ThemeEntity
import roomescape.theme.infrastructure.persistence.ThemeRepository
import roomescape.theme.web.ThemeCreateRequest
import roomescape.theme.web.ThemeRetrieveResponse
import roomescape.util.TsidFactory
import roomescape.util.ThemeFixture
class ThemeServiceTest : FunSpec({
val themeRepository: ThemeRepository = mockk()
val themeService = ThemeService(TsidFactory, themeRepository)
context("findThemeById") {
val themeId = 1L
test("조회 성공") {
val theme: ThemeEntity = ThemeFixture.create(id = themeId)
every {
themeRepository.findByIdOrNull(themeId)
} returns theme
theme.id shouldBe themeId
}
test("ID로 테마를 찾을 수 없으면 400 예외를 던진다.") {
every {
themeRepository.findByIdOrNull(themeId)
} returns null
val exception = shouldThrow<ThemeException> {
themeService.findById(themeId)
}
exception.errorCode shouldBe ThemeErrorCode.THEME_NOT_FOUND
}
}
context("findAllThemes") {
test("모든 테마를 조회한다.") {
val themes = listOf(ThemeFixture.create(id = 1, name = "t1"), ThemeFixture.create(id = 2, name = "t2"))
every {
themeRepository.findAll()
} returns themes
assertSoftly(themeService.findThemes()) {
this.themes.size shouldBe themes.size
this.themes[0].name shouldBe "t1"
this.themes[1].name shouldBe "t2"
}
}
}
context("save") {
val request = ThemeCreateRequest(
name = "New Theme",
description = "Description",
thumbnail = "http://example.com/thumbnail.jpg"
)
test("저장 성공") {
every {
themeRepository.existsByName(request.name)
} returns false
every {
themeRepository.save(any())
} returns ThemeFixture.create(
id = 1L,
name = request.name,
description = request.description,
thumbnail = request.thumbnail
)
val response: ThemeRetrieveResponse = themeService.createTheme(request)
assertSoftly(response) {
this.id shouldBe 1L
this.name shouldBe request.name
this.description shouldBe request.description
this.thumbnail shouldBe request.thumbnail
}
}
test("테마 이름이 중복되면 409 예외를 던진다.") {
every {
themeRepository.existsByName(request.name)
} returns true
val exception = shouldThrow<ThemeException> {
themeService.createTheme(request)
}
exception.errorCode shouldBe ThemeErrorCode.THEME_NAME_DUPLICATED
}
}
context("deleteById") {
test("이미 예약 중인 테마라면 409 예외를 던진다.") {
val themeId = 1L
every {
themeRepository.isReservedTheme(themeId)
} returns true
val exception = shouldThrow<ThemeException> {
themeService.deleteTheme(themeId)
}
exception.errorCode shouldBe ThemeErrorCode.THEME_ALREADY_RESERVED
}
}
})