From b0b0c0f6c38dcdb066c0d9a03a4c5226d2954757 Mon Sep 17 00:00:00 2001 From: Gleb Koval Date: Sun, 31 Dec 2023 14:56:04 +0600 Subject: [PATCH 1/2] Implement multipart tests --- src/test/kotlin/backup/BackupClientTest.kt | 23 +++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/src/test/kotlin/backup/BackupClientTest.kt b/src/test/kotlin/backup/BackupClientTest.kt index 74be479..8a4c99f 100644 --- a/src/test/kotlin/backup/BackupClientTest.kt +++ b/src/test/kotlin/backup/BackupClientTest.kt @@ -6,6 +6,7 @@ import org.junit.jupiter.api.* import org.junit.jupiter.api.Assertions.* import java.io.File import kotlin.io.path.* +import kotlin.random.Random val bucketName = System.getenv("BACKUP_BUCKET") ?: "teamcity-executors-test-task" @@ -17,7 +18,7 @@ class BackupClientTest { fun `before each`() = runBlocking { s3 = S3Client.fromEnvironment {} - backupClient = BackupClient(s3, bucketName) + backupClient = BackupClient(s3, bucketName, 1024 * 1024 * 10) } @AfterEach @@ -49,6 +50,26 @@ class BackupClientTest { Path("_test/README.md").apply { writeText("# This is a test directory structure.") }, ) }, + "single large file" to { + val bytes = ByteArray(1024 * 1024 * 32) + Random.nextBytes(bytes) + listOf( + Path("_test.txt").apply { writeBytes(bytes) } + ) + }, + "large directory structure" to { + val bytes1 = ByteArray(1024 * 1024 * 32) + val bytes2 = ByteArray(1024 * 1024 * 48) + listOf( + Path("_test").createDirectory(), + Path("_test/a.txt").apply { writeBytes(bytes1) }, + Path("_test/folder").createDirectory(), + Path("_test/another-folder").createDirectory(), + Path("_test/another-folder/b").apply { writeText("This is file B\n") }, + Path("_test/another-folder/c.txt").createFile(), + Path("_test/README.md").apply { writeBytes(bytes2) }, + ) + } ).map { (name, pathsGen) -> DynamicTest.dynamicTest(name) { val paths = pathsGen() -- 2.40.1 From 2a07859e5044a548d408e5ffdf47cf5c253a0e47 Mon Sep 17 00:00:00 2001 From: Gleb Koval Date: Sun, 31 Dec 2023 14:59:41 +0600 Subject: [PATCH 2/2] ktlint format --- src/test/kotlin/backup/BackupClientTest.kt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/test/kotlin/backup/BackupClientTest.kt b/src/test/kotlin/backup/BackupClientTest.kt index 8a4c99f..ae825df 100644 --- a/src/test/kotlin/backup/BackupClientTest.kt +++ b/src/test/kotlin/backup/BackupClientTest.kt @@ -54,7 +54,7 @@ class BackupClientTest { val bytes = ByteArray(1024 * 1024 * 32) Random.nextBytes(bytes) listOf( - Path("_test.txt").apply { writeBytes(bytes) } + Path("_test.txt").apply { writeBytes(bytes) }, ) }, "large directory structure" to { @@ -69,7 +69,7 @@ class BackupClientTest { Path("_test/another-folder/c.txt").createFile(), Path("_test/README.md").apply { writeBytes(bytes2) }, ) - } + }, ).map { (name, pathsGen) -> DynamicTest.dynamicTest(name) { val paths = pathsGen() -- 2.40.1