Skip to content

Commit

Permalink
add Paths.asByteStream e2e test
Browse files Browse the repository at this point in the history
  • Loading branch information
lauzadis committed Jan 19, 2024
1 parent fc41fd4 commit 073214f
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions services/s3/e2eTest/src/S3IntegrationTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import org.junit.jupiter.api.AfterAll
import org.junit.jupiter.api.BeforeAll
import org.junit.jupiter.api.TestInstance
import java.io.File
import java.nio.file.Paths
import java.util.UUID
import kotlin.test.Test
import kotlin.test.assertContains
Expand Down Expand Up @@ -108,6 +109,30 @@ class S3BucketOpsIntegrationTest {
assertEquals(contents, roundTrippedContents)
}

@Test
fun testPutObjectFromPathAsByteStream(): Unit = runBlocking {
val tempFile = RandomTempFile(1024)
val keyName = "put-obj-from-path-as-byte-stream.txt"

withTimeout(5.seconds) {
client.putObject {
bucket = testBucket
key = keyName
body = Paths.get(tempFile.path).asByteStream()
}
}

val req = GetObjectRequest {
bucket = testBucket
key = keyName
}
val roundTrippedContents = client.getObject(req) { it.body?.decodeToString() }

val contents = tempFile.readText()
assertEquals(contents, roundTrippedContents)
}


@Test
fun testGetEmptyObject(): Unit = runBlocking {
// See https://github.com/awslabs/aws-sdk-kotlin/issues/1014
Expand Down

0 comments on commit 073214f

Please sign in to comment.