Skip to content

Commit

Permalink
Add supported versions ids for ios
Browse files Browse the repository at this point in the history
  • Loading branch information
adamfilipow92 committed Nov 20, 2020
1 parent 7d52558 commit 9760db9
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 3 deletions.
3 changes: 2 additions & 1 deletion test_runner/src/main/kotlin/ftl/args/ValidateIosArgs.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package ftl.args

import ftl.args.yml.Type
import ftl.ios.IosCatalog
import ftl.ios.IosCatalog.getSupportedVersionId
import ftl.run.exception.FlankConfigurationError
import ftl.run.exception.IncompatibleTestDimensionError

Expand Down Expand Up @@ -66,7 +67,7 @@ private fun IosArgs.assertXcodeSupported() = when {

private fun IosArgs.assertDevicesSupported() = devices.forEach { device ->
if (!IosCatalog.supportedDevice(device.model, device.version, this.project))
throw IncompatibleTestDimensionError("iOS ${device.version} on ${device.model} is not a supported device")
throw IncompatibleTestDimensionError("iOS ${device.version} on ${device.model} is not a supported\nSupported version ids for '${device.model}': ${device.getSupportedVersionId(project).joinToString { it }}")
}

private fun IosArgs.assertTestFiles() {
Expand Down
4 changes: 4 additions & 0 deletions test_runner/src/main/kotlin/ftl/ios/IosCatalog.kt
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package ftl.ios

import com.google.api.services.testing.model.IosDeviceCatalog
import ftl.config.Device
import ftl.environment.asPrintableTable
import ftl.environment.common.asPrintableTable
import ftl.environment.getLocaleDescription
Expand Down Expand Up @@ -51,6 +52,9 @@ object IosCatalog {
projectId: String
) = iosDeviceCatalog(projectId).models.find { it.id == modelId }?.supportedVersionIds?.contains(versionId) ?: false

fun Device.getSupportedVersionId(projectId: String): List<String> = iosDeviceCatalog(projectId).models.find { it.id == model }?.supportedVersionIds
?: emptyList()

// Device catalogMap is different depending on the project id
private fun iosDeviceCatalog(
projectId: String
Expand Down
4 changes: 2 additions & 2 deletions test_runner/src/test/kotlin/ftl/args/IosArgsTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -129,8 +129,8 @@ flank:

@Test
fun `args invalidDeviceExits`() {
assertThrowsWithMessage(Throwable::class, "iOS 99.9 on iphoneZ is not a supported device") {
val invalidDevice = mutableListOf(Device("iphoneZ", "99.9"))
assertThrowsWithMessage(Throwable::class, "iOS 11.2 on iphonexsmax is not a supported\nSupported version ids for 'iphonexsmax': 12.0, 12.1") {
val invalidDevice = mutableListOf(Device("iphonexsmax", "11.2"))
createIosArgs(
config = defaultIosConfig().apply {
common.gcloud.devices = invalidDevice
Expand Down

0 comments on commit 9760db9

Please sign in to comment.