Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,11 @@ internal interface BlobVisitor {
val fileName: String
get() = gcsPath.path.substringAfterLast('/')

/**
* The size of the blob
*/
val size: Long

/**
* Opens the input stream to the blob. You must make sure to close it after using it.
*/
Expand All @@ -288,4 +293,6 @@ private class BlobVisitorImpl(
override fun toString(): String {
return "Blob($gcsPath)"
}

override val size: Long = blob.size
}
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,11 @@ interface TestRunnerService {
* Creates an [InputStream] for the file. Note that you must close it after using.
*/
fun openInputStream(): InputStream

/**
* Size of the file.
*/
val size: Long
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -347,6 +347,7 @@ internal class TestRunnerServiceImpl internal constructor(
private val blobVisitor: BlobVisitor
) : TestRunnerService.ResultFileResource {
override val gcsPath = blobVisitor.gcsPath
override val size = blobVisitor.size
override fun openInputStream(): InputStream = blobVisitor.obtainInputStream()
override fun toString(): String {
return "ResultFile('$gcsPath')"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,9 @@ internal class FakeGoogleCloudApi(
get() = entry.key.path.substringAfter(gcsPath.path).trimStart('/')
override val gcsPath: GcsPath
get() = entry.key
override val size: Long
get() = artifacts[gcsPath]?.size?.toLong() ?: 0

override fun obtainInputStream(): InputStream {
return entry.value.inputStream()
}
Expand All @@ -71,6 +74,9 @@ internal class FakeGoogleCloudApi(
get() = ""
override val gcsPath: GcsPath
get() = gcsPath
override val size: Long
get() = artifacts[gcsPath]?.size?.toLong() ?: 0

override fun obtainInputStream(): InputStream {
return artifacts[gcsPath]?.inputStream() ?: InputStream.nullInputStream()
}
Expand Down
Loading