Skip to content

Instantly share code, notes, and snippets.

@stella6767
Created July 28, 2022 05:23
Show Gist options
  • Save stella6767/649de28af6fa2aa60f3528eb6f047be5 to your computer and use it in GitHub Desktop.
Save stella6767/649de28af6fa2aa60f3528eb6f047be5 to your computer and use it in GitHub Desktop.
kotiln + junit5 with MockmultipartTest
@Test
@DisplayName("s3파일 업로드 테스트")
fun s3FileUploadTest(){
val imgPath = "src/main/resources/static/img"
val mockFile:MultipartFile = MockMultipartFile(
"test1",
"test1.png",
"image/png",
FileInputStream("$imgPath/test1.png")
)
// log.info { "mockFile $mockFile" }
// val convert = s3FileUploader.convert(mockFile)
// log.info { "convert $convert" }
// val upload = s3FileUploader.upload(convert.get(), S3FileUploader.songRawDirName)
// log.info { "upload $upload" }
//s3FileUploader.removeNewFile()
this.mockMvc.perform(multipart("/song")
.file("songFile",mockFile.bytes)
.param("name","song1"))
.andExpect(MockMvcResultMatchers.status().isOk)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment