Skip to content

Commit a3bdf4b

Browse files
committed
Update kotlin upload tests for input files
1 parent 8346c7e commit a3bdf4b

File tree

4 files changed

+34
-6
lines changed

4 files changed

+34
-6
lines changed

tests/KotlinJava11Test.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ class KotlinJava11Test extends Base
1919
...Base::BAR_RESPONSES,
2020
...Base::GENERAL_RESPONSES,
2121
...Base::LARGE_FILE_RESPONSES,
22+
...Base::LARGE_FILE_RESPONSES,
23+
...Base::LARGE_FILE_RESPONSES,
2224
...Base::EXCEPTION_RESPONSES
2325
];
2426
}

tests/KotlinJava17Test.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ class KotlinJava17Test extends Base
1919
...Base::BAR_RESPONSES,
2020
...Base::GENERAL_RESPONSES,
2121
...Base::LARGE_FILE_RESPONSES,
22+
...Base::LARGE_FILE_RESPONSES,
23+
...Base::LARGE_FILE_RESPONSES,
2224
...Base::EXCEPTION_RESPONSES
2325
];
2426
}

tests/KotlinJava8Test.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ class KotlinJava8Test extends Base
1919
...Base::BAR_RESPONSES,
2020
...Base::GENERAL_RESPONSES,
2121
...Base::LARGE_FILE_RESPONSES,
22+
...Base::LARGE_FILE_RESPONSES,
23+
...Base::LARGE_FILE_RESPONSES,
2224
...Base::EXCEPTION_RESPONSES
2325
];
2426
}

tests/languages/kotlin/ServiceTest.kt

Lines changed: 28 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,9 @@ import com.google.gson.Gson
44
import io.appwrite.exceptions.AppwriteException
55
import io.appwrite.extensions.fromJson
66
import io.appwrite.extensions.toJson
7-
import io.appwrite.models.Mock
87
import io.appwrite.models.Error
8+
import io.appwrite.models.InputFile
9+
import io.appwrite.models.Mock
910
import io.appwrite.services.Bar
1011
import io.appwrite.services.Foo
1112
import io.appwrite.services.General
@@ -68,11 +69,32 @@ class ServiceTest {
6869
val result = general.redirect()
6970
writeToFile((result as Map<String, Any>)["result"] as String)
7071

71-
mock = general.upload("string", 123, listOf("string in array"), File("../../resources/file.png"))
72-
writeToFile(mock.result)
73-
74-
mock = general.upload("string", 123, listOf("string in array"), File("../../resources/large_file.mp4"))
75-
writeToFile(mock.result)
72+
try {
73+
mock = general.upload("string", 123, listOf("string in array"), InputFile.fromPath("../../resources/file.png"))
74+
writeToFile(mock.result)
75+
} catch (ex: Exception) {
76+
writeToFile(ex.toString())
77+
}
78+
try {
79+
mock = general.upload("string", 123, listOf("string in array"), InputFile.fromPath("../../resources/large_file.mp4"))
80+
writeToFile(mock.result)
81+
} catch (ex: Exception) {
82+
writeToFile(ex.toString())
83+
}
84+
try {
85+
var bytes = File("../../resources/file.png").readBytes()
86+
mock = general.upload("string", 123, listOf("string in array"), InputFile.fromBytes(bytes, "file.png", "image/png"))
87+
writeToFile(mock.result)
88+
} catch (ex: Exception) {
89+
writeToFile(ex.toString())
90+
}
91+
try {
92+
var bytes = File("../../resources/large_file.mp4").readBytes()
93+
mock = general.upload("string", 123, listOf("string in array"), InputFile.fromBytes(bytes, "large_file.mp4", "video/mp4"))
94+
writeToFile(mock.result)
95+
} catch (ex: Exception) {
96+
writeToFile(ex.toString())
97+
}
7698

7799
try {
78100
general.error400()

0 commit comments

Comments
 (0)