-
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.
Merge branch 'master' into #835-ios-software
- Loading branch information
Showing
13 changed files
with
191 additions
and
14 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
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/android/versions/AndroidVersionsCommand.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.android.versions | ||
|
||
import picocli.CommandLine | ||
|
||
@CommandLine.Command( | ||
name = "versions", | ||
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"], | ||
subcommands = [AndroidVersionsListCommand::class], | ||
usageHelpAutoWidth = true | ||
) | ||
class AndroidVersionsCommand : Runnable { | ||
override fun run() { | ||
CommandLine.usage(AndroidVersionsCommand(), System.out) | ||
} | ||
} |
30 changes: 30 additions & 0 deletions
30
...nner/src/main/kotlin/ftl/cli/firebase/test/android/versions/AndroidVersionsListCommand.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.android.versions | ||
|
||
import ftl.android.AndroidCatalog.supportedVersionsAsTable | ||
import ftl.args.AndroidArgs | ||
import ftl.config.FtlConstants | ||
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 Android OS versions available to test against"], | ||
usageHelpAutoWidth = true | ||
) | ||
class AndroidVersionsListCommand : Runnable { | ||
override fun run() { | ||
println(supportedVersionsAsTable(AndroidArgs.load(Paths.get(configPath)).project)) | ||
} | ||
|
||
@CommandLine.Option(names = ["-c", "--config"], description = ["YAML config file path"]) | ||
var configPath: String = FtlConstants.defaultAndroidConfig | ||
|
||
@CommandLine.Option(names = ["-h", "--help"], usageHelp = true, description = ["Prints this help message"]) | ||
var usageHelpRequested: Boolean = false | ||
} |
39 changes: 39 additions & 0 deletions
39
test_runner/src/main/kotlin/ftl/environment/ListAndroidSofwareVersions.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,39 @@ | ||
package ftl.environment | ||
|
||
import com.google.api.services.testing.model.AndroidVersion | ||
import com.google.api.services.testing.model.Date | ||
import ftl.reports.api.twoDigitString | ||
import ftl.util.applyColorsUsing | ||
import ftl.util.buildTable | ||
|
||
fun List<AndroidVersion>.asPrintableTable() = createTestEnvironmentInfo().createAndroidSoftwareVersionsTable() | ||
|
||
private fun List<AndroidVersion>.createTestEnvironmentInfo() = | ||
fold(mutableMapOf<String, MutableList<String>>()) { softwareInfo, softwareVersion -> | ||
softwareInfo.apply { | ||
getOrCreateList(OS_VERSION_ID).add(softwareVersion.id.orUnknown()) | ||
getOrCreateList(VERSION).add(softwareVersion.versionString.orUnknown()) | ||
getOrCreateList(CODE_NAME).add(softwareVersion.codeName.orUnknown()) | ||
getOrCreateList(API_LEVEL).add(softwareVersion.apiLevel?.toString().orUnknown()) | ||
getOrCreateList(RELEASE_DATE).add(softwareVersion.releaseDate.printableReleaseDate()) | ||
getOrCreateList(TAGS).add(softwareVersion.tags.orEmpty().joinToString()) | ||
} | ||
} | ||
|
||
private fun Date?.printableReleaseDate() = | ||
if (this == null || year == null || month == null || day == null) "UNKNOWN" | ||
else "$year-${month.twoDigitString()}-${day.twoDigitString()}" | ||
|
||
private fun TestEnvironmentInfo.createAndroidSoftwareVersionsTable() = buildTable( | ||
createTableColumnFor(OS_VERSION_ID), | ||
createTableColumnFor(VERSION), | ||
createTableColumnFor(CODE_NAME), | ||
createTableColumnFor(API_LEVEL), | ||
createTableColumnFor(RELEASE_DATE), | ||
createTableColumnFor(TAGS).applyColorsUsing(tagToSystemOutColorMapper) | ||
) | ||
|
||
const val VERSION = "VERSION" | ||
const val CODE_NAME = "CODE_NAME" | ||
const val API_LEVEL = "API_LEVEL" | ||
const val RELEASE_DATE = "RELEASE_DATE" |
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
13 changes: 0 additions & 13 deletions
13
...nner/src/test/kotlin/ftl/cli/firebase/test/android/models/AndroidModelsListCommandTest.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
16 changes: 16 additions & 0 deletions
16
.../src/test/kotlin/ftl/cli/firebase/test/android/versions/AndroidVersionsListCommandTest.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,16 @@ | ||
package ftl.cli.firebase.test.android.versions | ||
|
||
import com.google.common.truth.Truth.assertThat | ||
import org.junit.Test | ||
import picocli.CommandLine | ||
|
||
class AndroidVersionsListCommandTest { | ||
|
||
@Test | ||
fun androidVersionsListCommandShouldParseConfig() { | ||
val cmd = AndroidVersionsListCommand() | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package ftl.reports.api | ||
|
||
import org.junit.Assert.assertEquals | ||
import org.junit.Test | ||
|
||
class UtilsTest { | ||
|
||
@Test | ||
fun `should add leading 0 to single digit integer`() { | ||
// given | ||
val expectedString = "05" | ||
|
||
// when | ||
val actual = 5.twoDigitString() | ||
|
||
// then | ||
assertEquals(expectedString, actual) | ||
} | ||
|
||
@Test | ||
fun `should not add leading 0 to two digits integer`() { | ||
// given | ||
val expectedString = "15" | ||
|
||
// when | ||
val actual = 15.twoDigitString() | ||
|
||
// then | ||
assertEquals(expectedString, actual) | ||
} | ||
} |