-
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.
#835 Added printing available iOS software versions
- Loading branch information
Piotr Adamczyk
committed
Jul 17, 2020
1 parent
2edb898
commit 73254a8
Showing
12 changed files
with
142 additions
and
29 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
21 changes: 21 additions & 0 deletions
21
test_runner/src/main/kotlin/ftl/cli/firebase/test/ios/versions/IosVersionsCommand.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,21 @@ | ||
package ftl.cli.firebase.test.ios.versions | ||
|
||
import picocli.CommandLine | ||
|
||
@CommandLine.Command( | ||
name = "versions", | ||
subcommands = [IosVersionsListCommand::class], | ||
headerHeading = "", | ||
synopsisHeading = "%n", | ||
descriptionHeading = "%n@|bold,underline Description:|@%n%n", | ||
parameterListHeading = "%n@|bold,underline Parameters:|@%n", | ||
optionListHeading = "%n@|bold,underline Options:|@%n", | ||
header = ["Information about available software versions"], | ||
description = ["Information about available software versions. For example prints list of available software versions"], | ||
usageHelpAutoWidth = true | ||
) | ||
class IosVersionsCommand : Runnable { | ||
override fun run() { | ||
CommandLine.usage(IosVersionsCommand(), System.out) | ||
} | ||
} |
30 changes: 30 additions & 0 deletions
30
test_runner/src/main/kotlin/ftl/cli/firebase/test/ios/versions/IosVersionsListCommand.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,30 @@ | ||
package ftl.cli.firebase.test.ios.versions | ||
|
||
import ftl.args.IosArgs | ||
import ftl.config.FtlConstants | ||
import ftl.ios.IosCatalog.softwareVersionsAsTable | ||
import picocli.CommandLine | ||
import java.nio.file.Paths | ||
|
||
@CommandLine.Command( | ||
name = "list", | ||
headerHeading = "", | ||
synopsisHeading = "%n", | ||
descriptionHeading = "%n@|bold,underline Description:|@%n%n", | ||
parameterListHeading = "%n@|bold,underline Parameters:|@%n", | ||
optionListHeading = "%n@|bold,underline Options:|@%n", | ||
header = ["List of OS versions available to test against"], | ||
description = ["Print current list of iOS versions available to test against"], | ||
usageHelpAutoWidth = true | ||
) | ||
class IosVersionsListCommand : Runnable { | ||
override fun run() { | ||
println(softwareVersionsAsTable(IosArgs.load(Paths.get(configPath)).project)) | ||
} | ||
|
||
@CommandLine.Option(names = ["-c", "--config"], description = ["YAML config file path"]) | ||
var configPath: String = FtlConstants.defaultIosConfig | ||
|
||
@CommandLine.Option(names = ["-h", "--help"], usageHelp = true, description = ["Prints this help message"]) | ||
var usageHelpRequested: Boolean = false | ||
} |
30 changes: 30 additions & 0 deletions
30
test_runner/src/main/kotlin/ftl/environment/ListIOsSofwareVersions.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,30 @@ | ||
package ftl.environment | ||
|
||
import com.google.api.services.testing.model.IosVersion | ||
import ftl.util.applyColorsUsing | ||
import ftl.util.buildTable | ||
|
||
fun List<IosVersion>.asPrintableTable() = createTestEnvironmentInfo().createIOsSoftwareVersionsTable() | ||
|
||
private fun List<IosVersion>.createTestEnvironmentInfo() = | ||
fold(mutableMapOf<String, MutableList<String>>()) { softwareInfo, softwareVersion -> | ||
softwareInfo.apply { | ||
getOrCreateList(OS_VERSION_ID).add(softwareVersion.id.orUnknown()) | ||
getOrCreateList(MAJOR_VERSION).add(softwareVersion.majorVersion?.toString().orEmpty()) | ||
getOrCreateList(MINOR_VERSION).add(softwareVersion.minorVersion?.toString().orEmpty()) | ||
getOrCreateList(TAGS).add(softwareVersion.tags.orEmpty().joinToString()) | ||
getOrCreateList(SUPPORTED_XCODE_VERSION_IDS).add(softwareVersion.supportedXcodeVersionIds.joinToString()) | ||
} | ||
} | ||
|
||
private fun TestEnvironmentInfo.createIOsSoftwareVersionsTable() = buildTable( | ||
createTableColumnFor(OS_VERSION_ID), | ||
createTableColumnFor(MAJOR_VERSION), | ||
createTableColumnFor(MINOR_VERSION), | ||
createTableColumnFor(TAGS).applyColorsUsing(tagToSystemOutColorMapper), | ||
createTableColumnFor(SUPPORTED_XCODE_VERSION_IDS) | ||
) | ||
|
||
private const val MAJOR_VERSION = "MAJOR_VERSION" | ||
private const val MINOR_VERSION = "MINOR_VERSION" | ||
private const val SUPPORTED_XCODE_VERSION_IDS = "SUPPORTED_XCODE_VERSION_IDS" |
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
28 changes: 0 additions & 28 deletions
28
test_runner/src/test/kotlin/ftl/cli/firebase/test/IosCommandTest.kt
This file was deleted.
Oops, something went wrong.
29 changes: 29 additions & 0 deletions
29
test_runner/src/test/kotlin/ftl/cli/firebase/test/ios/versions/IosVersionsListCommandTest.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,29 @@ | ||
package ftl.cli.firebase.test.ios.versions | ||
|
||
import com.google.common.truth.Truth.assertThat | ||
import ftl.config.FtlConstants | ||
import org.junit.Test | ||
import picocli.CommandLine | ||
|
||
class IosVersionsListCommandTest { | ||
|
||
@Test | ||
fun iosVersionsListCommandOptions() { | ||
val cmd = IosVersionsListCommand() | ||
assertThat(cmd.configPath).isEqualTo(FtlConstants.defaultIosConfig) | ||
cmd.configPath = "tmp" | ||
assertThat(cmd.configPath).isEqualTo("tmp") | ||
|
||
assertThat(cmd.usageHelpRequested).isFalse() | ||
cmd.usageHelpRequested = true | ||
assertThat(cmd.usageHelpRequested).isTrue() | ||
} | ||
|
||
@Test | ||
fun iosVersionsListCommandShouldParseConfig() { | ||
val cmd = IosVersionsListCommand() | ||
CommandLine(cmd).parseArgs("--config=a") | ||
|
||
assertThat(cmd.configPath).isEqualTo("a") | ||
} | ||
} |
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