-
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.
- Loading branch information
1 parent
4a71276
commit ca0595e
Showing
8 changed files
with
95 additions
and
47 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
package ftl.ios | ||
|
||
import com.google.api.services.testing.model.IosDeviceCatalog | ||
import ftl.gc.GcTesting | ||
import ftl.http.executeWithRetry | ||
|
||
|
@@ -9,17 +10,34 @@ import ftl.http.executeWithRetry | |
* note: 500 Internal Server Error is returned on invalid model id/version | ||
**/ | ||
object IosCatalog { | ||
private val xcodeVersions by lazy { | ||
iosDeviceCatalog.xcodeVersions.map { it.version } | ||
private val catalogMap: MutableMap<String, IosDeviceCatalog> = mutableMapOf() | ||
private val xcodeMap: MutableMap<String, List<String>> = mutableMapOf() | ||
|
||
fun xcodeVersions(projectId: String): List<String> { | ||
val cached = xcodeMap[projectId] | ||
if (cached != null) return cached | ||
|
||
val newVersions = iosDeviceCatalog(projectId).xcodeVersions.map { it.version } | ||
xcodeMap[projectId] = newVersions | ||
return newVersions | ||
} | ||
|
||
private val iosDeviceCatalog by lazy { | ||
// Device catalogMap is different depending on the project id | ||
fun iosDeviceCatalog(projectId: String): IosDeviceCatalog { | ||
val cached = catalogMap[projectId] | ||
if (cached != null) return cached | ||
|
||
try { | ||
GcTesting.get.testEnvironmentCatalog().get("ios").executeWithRetry().iosDeviceCatalog | ||
val newCatalog = GcTesting.get.testEnvironmentCatalog() | ||
.get("ios") | ||
.setProjectId(projectId) | ||
.executeWithRetry().iosDeviceCatalog | ||
catalogMap[projectId] = newCatalog | ||
return newCatalog | ||
} catch (e: java.lang.Exception) { | ||
throw java.lang.RuntimeException( | ||
""" | ||
Unable to access the test environment catalog. Firebase Test Lab for iOS is currently in beta. | ||
Unable to access the test environment catalogMap. Firebase Test Lab for iOS is currently in beta. | ||
Request access for your project via the following form: | ||
https://goo.gl/forms/wAxbiNEP2pxeIRG82 | ||
|
@@ -32,12 +50,12 @@ If you are still having issues, please email [email protected] for sup | |
} | ||
} | ||
|
||
fun supportedXcode(version: String): Boolean { | ||
return xcodeVersions.contains(version) | ||
fun supportedXcode(version: String, projectId: String): Boolean { | ||
return xcodeVersions(projectId).contains(version) | ||
} | ||
|
||
fun supportedDevice(modelId: String, versionId: String): Boolean { | ||
val model = iosDeviceCatalog.models.find { it.id == modelId } | ||
fun supportedDevice(modelId: String, versionId: String, projectId: String): Boolean { | ||
val model = iosDeviceCatalog(projectId).models.find { it.id == modelId } | ||
return model?.supportedVersionIds?.contains(versionId) ?: false | ||
} | ||
} |
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