Skip to content

Commit

Permalink
fix: Filter devices without supported versions (#1967)
Browse files Browse the repository at this point in the history
Fixes #1892 

## Test Plan
> How do we know the code works?

1. run `./gradlew flankFullRun`
2. run `flank firebase test ios models list` and compare with `gcloud firebase test ios models list` -- there should be no different
3. run `flank firebase test android models list` and compare with `gcloud firebase test android models list` -- there should be no different

## Checklist

- [x] Unit tested
  • Loading branch information
pawelpasterz authored May 25, 2021
1 parent 627b75c commit e933280
Show file tree
Hide file tree
Showing 7 changed files with 314 additions and 407 deletions.
18 changes: 14 additions & 4 deletions test_runner/src/main/kotlin/ftl/client/google/AndroidCatalog.kt
Original file line number Diff line number Diff line change
Expand Up @@ -26,19 +26,26 @@ object AndroidCatalog {
.setProjectId(projectId)
.executeWithRetry()
.androidDeviceCatalog
.filterDevicesWithoutSupportedVersions()
}

private fun AndroidDeviceCatalog.filterDevicesWithoutSupportedVersions() =
setModels(models.filterNotNull().filter { it.supportedVersionIds?.isNotEmpty() ?: false })

fun getModels(projectId: String): List<AndroidModel> = deviceCatalog(projectId).models.orEmpty()

fun supportedVersionsAsTable(projectId: String) = fetchAndroidOsVersion(projectId).toCliTable()

fun describeSoftwareVersion(projectId: String, versionId: String) = fetchAndroidOsVersion(projectId).getDescription(versionId)
fun describeSoftwareVersion(projectId: String, versionId: String) =
fetchAndroidOsVersion(projectId).getDescription(versionId)

private fun getVersionsList(projectId: String) = deviceCatalog(projectId).versions

fun supportedOrientations(projectId: String): List<Orientation> = deviceCatalog(projectId).runtimeConfiguration.orientations
fun supportedOrientations(projectId: String): List<Orientation> =
deviceCatalog(projectId).runtimeConfiguration.orientations

private fun getLocaleDescription(projectId: String, locale: String) = getLocales(projectId).getLocaleDescription(locale)
private fun getLocaleDescription(projectId: String, locale: String) =
getLocales(projectId).getLocaleDescription(locale)

internal fun getLocales(projectId: String) = deviceCatalog(projectId).runtimeConfiguration.locales

Expand All @@ -60,7 +67,10 @@ object AndroidCatalog {
logLn("Unable to find device type for $modelId. PHYSICAL used as fallback in cost calculations")
}

return form.equals(DeviceType.VIRTUAL.name, ignoreCase = true) || form.equals(DeviceType.EMULATOR.name, ignoreCase = true)
return form.equals(DeviceType.VIRTUAL.name, ignoreCase = true) || form.equals(
DeviceType.EMULATOR.name,
ignoreCase = true
)
}
}

Expand Down
4 changes: 4 additions & 0 deletions test_runner/src/main/kotlin/ftl/client/google/IosCatalog.kt
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ object IosCatalog {
.setProjectId(projectId)
.executeWithRetry()
.iosDeviceCatalog
.filterDevicesWithoutSupportedVersions()
}
} catch (e: java.lang.Exception) {
throw java.lang.RuntimeException(
Expand All @@ -68,4 +69,7 @@ If you are still having issues, please email ftl-ios-feedback@google.com for sup
e
)
}

private fun IosDeviceCatalog.filterDevicesWithoutSupportedVersions() =
setModels(models.filterNotNull().filter { it.supportedVersionIds?.isNotEmpty() ?: false })
}
2 changes: 1 addition & 1 deletion test_runner/src/test/kotlin/ftl/args/IosArgsTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ flank:

@Test
fun `args invalidDeviceExits`() {
assertThrowsWithMessage(Throwable::class, "iOS 11.2 on iphonexsmax is not a supported\nSupported version ids for 'iphonexsmax': 12.0, 12.1") {
assertThrowsWithMessage(Throwable::class, "iOS 11.2 on iphonexsmax is not a supported\nSupported version ids for 'iphonexsmax': 12.1, 12.3") {
val invalidDevice = mutableListOf(Device("iphonexsmax", "11.2"))
createIosArgs(
config = defaultIosConfig().apply {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class ValidateIosArgsTest {
fun supportedDevice() {
assertThat(isDeviceSupported("bogus", "11.2", projectId)).isFalse()
assertThat(isDeviceSupported("iphone8", "bogus", projectId)).isFalse()
assertThat(isDeviceSupported("iphone8", "11.2", projectId)).isTrue()
assertThat(isDeviceSupported("iphone8", "12.0", projectId)).isTrue()
}

@Test
Expand Down
Loading

0 comments on commit e933280

Please sign in to comment.