Skip to content

Commit

Permalink
apply detekt for a test file
Browse files Browse the repository at this point in the history
  • Loading branch information
ForteScarlet committed Oct 10, 2024
1 parent 899a470 commit 56f5856
Showing 1 changed file with 31 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -47,28 +47,34 @@ class InputFileTests {
length: Int, assertText: String,
inputFile: InputFile,
) {
HttpClient(MockEngine { req ->
val body = req.body
assertIs<MultiPartFormDataContent>(body)
val boundary = body.boundary
val bodyText = body.toByteArray().decodeToString()

assertEquals(
"--$boundary$CLRF" +
HttpClient(
MockEngine { req ->
val body = req.body
assertIs<MultiPartFormDataContent>(body)
val boundary = body.boundary
val bodyText = body.toByteArray().decodeToString()

assertEquals(
"--$boundary$CLRF" +
"Content-Disposition: form-data; name=file$CLRF" +
"Content-Length: $length$CLRF" +
CLRF +
"$assertText$CLRF" +
"--$boundary--$CLRF",
bodyText
)
bodyText
)

respondOk()
}).use {
respondOk()
}
).use {
it.post("") {
setBody(MultiPartFormDataContent(formData {
inputFile.includeTo("file", formBuilder = this)
}))
setBody(
MultiPartFormDataContent(
formData {
inputFile.includeTo("file", formBuilder = this)
}
)
)
}
}
}
Expand All @@ -87,15 +93,23 @@ class InputFileTests {
val realText = "Hello, World"
val bytes = realText.toByteArray()

assertInputFileByMockClient(bytes.size, realText, InputFile(InputProvider(bytes.size.toLong()) { ByteReadPacket(bytes) }))
assertInputFileByMockClient(
bytes.size,
realText,
InputFile(InputProvider(bytes.size.toLong()) { ByteReadPacket(bytes) })
)
}

@Test
fun channelProviderInputFile() = runTest {
val realText = "Hello, World"
val bytes = realText.toByteArray()

assertInputFileByMockClient(bytes.size, realText, InputFile(ChannelProvider(bytes.size.toLong()) { ByteReadChannel(realText) }))
assertInputFileByMockClient(
bytes.size,
realText,
InputFile(ChannelProvider(bytes.size.toLong()) { ByteReadChannel(realText) })
)
}

@Test
Expand Down

0 comments on commit 56f5856

Please sign in to comment.