-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
110 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 0 additions & 19 deletions
19
src/main/kotlin/site/qbox/qboxserver/domain/image/ImageCtrl.kt
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 0 additions & 7 deletions
7
src/test/kotlin/site/qbox/qboxserver/domain/image/ImageCtrlTest.kt
This file was deleted.
Oops, something went wrong.
27 changes: 27 additions & 0 deletions
27
src/test/kotlin/site/qbox/qboxserver/domain/image/ImageSvcTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,34 @@ | ||
package site.qbox.qboxserver.domain.image | ||
|
||
import com.ninjasquad.springmockk.MockkBean | ||
import io.kotest.core.spec.style.DescribeSpec | ||
import io.kotest.extensions.spring.SpringExtension | ||
import io.kotest.matchers.shouldBe | ||
import io.mockk.every | ||
import org.springframework.beans.factory.annotation.Autowired | ||
import org.springframework.boot.test.context.SpringBootTest | ||
import org.springframework.mock.web.MockMultipartFile | ||
|
||
@SpringBootTest | ||
class ImageSvcTest : DescribeSpec() { | ||
|
||
override fun extensions() = listOf(SpringExtension) | ||
|
||
@Autowired | ||
lateinit var imageSvc: ImageSvc | ||
|
||
@MockkBean | ||
lateinit var imageRepo: ImageRepo | ||
|
||
val image = MockMultipartFile("asdfasdf.jpg", byteArrayOf(9)) | ||
init { | ||
it("저장을 수행한다.") { | ||
val savedUrl = "https://hello.com/user/kkkkk-sdf.jpg" | ||
every { imageRepo.save(image, any(String::class)) } returns savedUrl | ||
|
||
val result = imageSvc.save(image) | ||
result.location shouldBe savedUrl | ||
} | ||
} | ||
|
||
} |
37 changes: 37 additions & 0 deletions
37
src/test/kotlin/site/qbox/qboxserver/domain/image/ImageValidatorTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,44 @@ | ||
package site.qbox.qboxserver.domain.image | ||
|
||
import io.kotest.assertions.throwables.shouldNotThrow | ||
import io.kotest.assertions.throwables.shouldThrow | ||
import io.kotest.core.spec.style.DescribeSpec | ||
import io.kotest.extensions.spring.SpringExtension | ||
import org.springframework.beans.factory.annotation.Autowired | ||
import org.springframework.boot.test.context.SpringBootTest | ||
import org.springframework.mock.web.MockMultipartFile | ||
import site.qbox.qboxserver.domain.image.exception.NotAllowedImageException | ||
|
||
@SpringBootTest | ||
class ImageValidatorTest : DescribeSpec() { | ||
|
||
override fun extensions() = listOf(SpringExtension) | ||
|
||
@Autowired | ||
lateinit var imageValidator: ImageValidator | ||
|
||
init { | ||
it("검증을 수행한다") { | ||
val image = MockMultipartFile("hello.jpg", byteArrayOf(9)) | ||
shouldNotThrow<NotAllowedImageException> { | ||
imageValidator.validate(image) | ||
} | ||
} | ||
|
||
it("확장자가 명시되어있지 않으면 예외를 반환한다") { | ||
val image = MockMultipartFile("asdfasdf", byteArrayOf(9)) | ||
shouldThrow<NotAllowedImageException> { | ||
imageValidator.validate(image) | ||
} | ||
} | ||
|
||
it("허용하지 않은 확장자면 예외를 반환한다") { | ||
val image = MockMultipartFile("hello.txt", byteArrayOf(9)) | ||
shouldThrow<NotAllowedImageException> { | ||
imageValidator.validate(image) | ||
} | ||
} | ||
|
||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package site.qbox.qboxserver.study | ||
|
||
import io.kotest.assertions.throwables.shouldNotThrow | ||
import io.kotest.assertions.throwables.shouldThrow | ||
import io.kotest.core.spec.style.DescribeSpec | ||
|
||
class RequireTest : DescribeSpec() { | ||
|
||
|
||
fun requireIn(value: String) { | ||
val list = listOf("A", "B", "C", "D", "E", "F") | ||
require(value in list) | ||
} | ||
|
||
init { | ||
it("in 값에 포함되면 예외를 반환하지 않는다.") { | ||
shouldNotThrow<IllegalArgumentException> { | ||
requireIn("A") | ||
} | ||
} | ||
it("in 값에 포함되지 않으면 예외를 반환한다.") { | ||
shouldThrow<IllegalArgumentException> { | ||
requireIn("KK") | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters