-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Set properly encrypted file size when uploading (#101)
- Loading branch information
Showing
10 changed files
with
95 additions
and
89 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 10 additions & 19 deletions
29
src/test/kotlin/com/pubnub/api/legacy/endpoints/files/TestsWithFiles.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,20 @@ | ||
package com.pubnub.api.legacy.endpoints.files | ||
|
||
import org.junit.rules.TemporaryFolder | ||
import java.io.File | ||
import java.io.IOException | ||
import java.nio.file.Files | ||
import java.util.ArrayList | ||
import java.util.Collections | ||
import org.junit.jupiter.api.BeforeEach | ||
import java.util.UUID | ||
|
||
interface TestsWithFiles { | ||
val temporaryFolder: TemporaryFolder | ||
|
||
fun getTemporaryFile(filename: String, vararg content: String?): File { | ||
return try { | ||
val file = temporaryFolder.newFile(filename) | ||
val lines = ArrayList<String>() | ||
Collections.addAll<String>(lines, *content) | ||
Files.write(file.toPath(), lines) | ||
file | ||
} catch (ex: IOException) { | ||
// fail | ||
throw RuntimeException(ex.message, ex) | ||
} | ||
fun fileName() = _fileName | ||
|
||
fun inputStream(content: String = "content") = content.byteInputStream() | ||
|
||
@BeforeEach | ||
fun beforeEach() { | ||
_fileName = "file_${UUID.randomUUID()}" | ||
} | ||
|
||
companion object { | ||
val folder = TemporaryFolder() | ||
private lateinit var _fileName: String | ||
} | ||
} |
Oops, something went wrong.