-
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: Refactor os versions commands (#1833)
Fixes #1750 ## Test Plan > How do we know the code works? * Code is refactored according to the description in #1750 * os version commands (list and describe) works as before ## Checklist - [X] Unit tested
- Loading branch information
1 parent
7ce2e3e
commit ad3a74b
Showing
13 changed files
with
171 additions
and
45 deletions.
There are no files selected for viewing
11 changes: 11 additions & 0 deletions
11
test_runner/src/main/kotlin/ftl/adapter/AndroidOsVersionsFetch.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.OsVersion | ||
import ftl.client.google.androidOsVersions | ||
|
||
object AndroidOsVersionsFetch : | ||
OsVersion.Android.Fetch, | ||
(String) -> List<OsVersion.Android> by { | ||
androidOsVersions(it).toApiModel() | ||
} |
11 changes: 11 additions & 0 deletions
11
test_runner/src/main/kotlin/ftl/adapter/IosVersionsFetch.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.OsVersion | ||
import ftl.client.google.iosOsVersions | ||
|
||
object IosVersionsFetch : | ||
OsVersion.Ios.Fetch, | ||
(String) -> List<OsVersion.Ios> by { | ||
iosOsVersions(it).toApiModel() | ||
} |
24 changes: 24 additions & 0 deletions
24
test_runner/src/main/kotlin/ftl/adapter/google/AndroidOsVersions.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,24 @@ | ||
package ftl.adapter.google | ||
|
||
import com.google.testing.model.AndroidVersion | ||
import com.google.testing.model.Date | ||
import com.google.testing.model.Distribution | ||
import ftl.api.OsVersion | ||
|
||
fun List<AndroidVersion>.toApiModel() = map { | ||
it.toApiModel() | ||
} | ||
|
||
private fun AndroidVersion.toApiModel() = OsVersion.Android( | ||
apiLevel, | ||
codeName, | ||
distribution?.toApiModel(), | ||
id, | ||
releaseDate?.toApiModel(), | ||
tags, | ||
versionString | ||
) | ||
|
||
private fun Distribution.toApiModel() = OsVersion.Distribution(marketShare, measurementTime) | ||
|
||
private fun Date.toApiModel() = OsVersion.Date(day, month, year) |
10 changes: 10 additions & 0 deletions
10
test_runner/src/main/kotlin/ftl/adapter/google/IosOsVersions.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,10 @@ | ||
package ftl.adapter.google | ||
|
||
import com.google.testing.model.IosVersion | ||
import ftl.api.OsVersion | ||
|
||
fun List<IosVersion>.toApiModel() = map { | ||
it.toApiModel() | ||
} | ||
|
||
private fun IosVersion.toApiModel() = OsVersion.Ios(id, majorVersion, minorVersion, supportedXcodeVersionIds, tags) |
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,39 @@ | ||
package ftl.api | ||
|
||
import ftl.adapter.AndroidOsVersionsFetch | ||
import ftl.adapter.IosVersionsFetch | ||
|
||
val fetchAndroidOsVersion: OsVersion.Android.Fetch get() = AndroidOsVersionsFetch | ||
val fetchIosOsVersion: OsVersion.Ios.Fetch get() = IosVersionsFetch | ||
|
||
object OsVersion { | ||
|
||
data class Android( | ||
val apiLevel: Int?, | ||
val codeName: String?, | ||
val distribution: Distribution?, | ||
val id: String?, | ||
val releaseDate: Date?, | ||
val tags: List<String>?, | ||
val versionString: String?, | ||
) { | ||
interface Fetch : (String) -> List<Android> | ||
} | ||
|
||
data class Ios( | ||
val id: String, | ||
val majorVersion: Int, | ||
val minorVersion: Int, | ||
val supportedXcodeVersionIds: List<String>, | ||
val tags: List<String>, | ||
) { | ||
interface Fetch : (String) -> List<Ios> | ||
} | ||
|
||
data class Distribution( | ||
val marketShare: Double, | ||
val measurementTime: String, | ||
) | ||
|
||
data class Date(val day: Int?, val month: Int?, val year: Int?) | ||
} |
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
24 changes: 24 additions & 0 deletions
24
test_runner/src/main/kotlin/ftl/client/google/OsVersion.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,24 @@ | ||
package ftl.client.google | ||
|
||
import com.google.testing.model.AndroidVersion | ||
import com.google.testing.model.IosVersion | ||
import ftl.gc.GcTesting | ||
import ftl.http.executeWithRetry | ||
|
||
fun androidOsVersions(projectId: String): List<AndroidVersion> = | ||
GcTesting.get.testEnvironmentCatalog() | ||
.get("android") | ||
.setProjectId(projectId) | ||
.executeWithRetry() | ||
.androidDeviceCatalog | ||
.versions | ||
.orEmpty() | ||
|
||
fun iosOsVersions(projectId: String): List<IosVersion> = | ||
GcTesting.get.testEnvironmentCatalog() | ||
.get("ios") | ||
.setProjectId(projectId) | ||
.executeWithRetry() | ||
.iosDeviceCatalog | ||
.versions | ||
.orEmpty() |
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
6 changes: 4 additions & 2 deletions
6
test_runner/src/main/kotlin/ftl/domain/ListAndroidVersions.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,14 +1,16 @@ | ||
package ftl.domain | ||
|
||
import flank.common.logLn | ||
import ftl.api.fetchAndroidOsVersion | ||
import ftl.args.AndroidArgs | ||
import ftl.client.google.AndroidCatalog | ||
import ftl.environment.android.toCliTable | ||
import java.nio.file.Paths | ||
|
||
interface ListAndroidVersions { | ||
val configPath: String | ||
} | ||
|
||
operator fun ListAndroidVersions.invoke() { | ||
logLn(AndroidCatalog.supportedVersionsAsTable(AndroidArgs.loadOrDefault(Paths.get(configPath)).project)) | ||
// TODO move toCliTable() to presentation layer during refactor of presentation after #1728 | ||
logLn(fetchAndroidOsVersion(AndroidArgs.loadOrDefault(Paths.get(configPath)).project).toCliTable()) | ||
} |
17 changes: 9 additions & 8 deletions
17
test_runner/src/main/kotlin/ftl/environment/android/AndroidSoftwareVersionDescription.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