-
Notifications
You must be signed in to change notification settings - Fork 119
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: data scratch file references (#1841)
- Loading branch information
Showing
19 changed files
with
113 additions
and
58 deletions.
There are no files selected for viewing
12 changes: 12 additions & 0 deletions
12
test_runner/src/main/kotlin/ftl/adapter/DownloadAsJunitXML.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 |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package ftl.adapter | ||
|
||
import ftl.adapter.google.toApiModel | ||
import ftl.api.FileReference | ||
import ftl.client.google.downloadAsJunitXml | ||
import ftl.reports.xml.model.JUnitTestResult | ||
|
||
object DownloadAsJunitXML : | ||
FileReference.DownloadAsXML, | ||
(FileReference) -> JUnitTestResult by { fileReference -> | ||
downloadAsJunitXml(fileReference).toApiModel() | ||
} |
11 changes: 11 additions & 0 deletions
11
test_runner/src/main/kotlin/ftl/adapter/GcStorageDownload.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 |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package ftl.adapter | ||
|
||
import ftl.adapter.google.toApiModel | ||
import ftl.api.FileReference | ||
import ftl.client.google.fileReferenceDownload | ||
|
||
object GcStorageDownload : | ||
FileReference.Download, | ||
(FileReference, Boolean, Boolean) -> FileReference by { fileReference, ifNeeded, ignoreErrors -> | ||
fileReferenceDownload(fileReference, ifNeeded, ignoreErrors).toApiModel(fileReference) | ||
} |
8 changes: 8 additions & 0 deletions
8
test_runner/src/main/kotlin/ftl/adapter/google/FileReferenceAdapter.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 |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package ftl.adapter.google | ||
|
||
import ftl.api.FileReference | ||
import ftl.reports.xml.model.JUnitTestResult | ||
|
||
internal fun String.toApiModel(fileReference: FileReference) = fileReference.copy(local = this) | ||
|
||
internal fun JUnitTestResult?.toApiModel() = JUnitTestResult(testsuites = this?.testsuites) |
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 |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package ftl.api | ||
|
||
import ftl.adapter.DownloadAsJunitXML | ||
import ftl.adapter.GcStorageDownload | ||
import ftl.reports.xml.model.JUnitTestResult | ||
|
||
val downloadFileReference: FileReference.Download get() = GcStorageDownload | ||
val downloadAsJunitXML: FileReference.DownloadAsXML get() = DownloadAsJunitXML | ||
|
||
data class FileReference( | ||
val local: String = "", | ||
val remote: String = "" | ||
) { | ||
|
||
interface Download : (FileReference, Boolean, Boolean) -> FileReference | ||
interface DownloadAsXML : (FileReference) -> JUnitTestResult | ||
} |
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
25 changes: 25 additions & 0 deletions
25
test_runner/src/main/kotlin/ftl/client/google/FileReference.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 |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package ftl.client.google | ||
|
||
import ftl.api.FileReference | ||
import ftl.reports.xml.model.JUnitTestResult | ||
import ftl.reports.xml.parseAllSuitesXml | ||
import ftl.run.exception.FlankGeneralError | ||
import java.nio.file.Paths | ||
|
||
internal fun fileReferenceDownload(fileReference: FileReference, ifNeeded: Boolean, ignoreErrors: Boolean): String { | ||
if (!ignoreErrors) { | ||
if (fileReference.local.isBlank() && fileReference.remote.isBlank()) throw FlankGeneralError("Cannot create empty FileReference") | ||
} | ||
return when { | ||
ifNeeded -> { | ||
if (fileReference.local.isNotBlank()) fileReference.local | ||
else gcStorageDownload(fileReference.remote, ignoreErrors) | ||
} | ||
else -> gcStorageDownload(fileReference.remote, ignoreErrors) | ||
} | ||
} | ||
|
||
internal fun downloadAsJunitXml(fileReference: FileReference): JUnitTestResult? = | ||
fileReferenceDownload(fileReference, ifNeeded = false, ignoreErrors = true) | ||
.takeIf { it.isNotEmpty() } | ||
?.let { parseAllSuitesXml(Paths.get(it)) } |
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
13 changes: 0 additions & 13 deletions
13
test_runner/src/main/kotlin/ftl/client/google/GcStorageAdapter.kt
This file was deleted.
Oops, something went wrong.
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
2 changes: 1 addition & 1 deletion
2
test_runner/src/main/kotlin/ftl/run/model/AndroidTestContext.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
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
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