Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

refactor: Describe ios versions #1906

Merged
merged 1 commit into from
May 10, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions test_runner/src/main/kotlin/ftl/domain/DescribeIosVersions.kt
Original file line number Diff line number Diff line change
@@ -1,17 +1,21 @@
package ftl.domain

import flank.common.logLn
import ftl.api.fetchIosOsVersion
import ftl.args.IosArgs
import ftl.client.google.IosCatalog
import ftl.presentation.Output
import ftl.run.exception.FlankConfigurationError
import ftl.run.exception.FlankGeneralError
import java.nio.file.Paths

interface DescribeIosVersions {
interface DescribeIosVersions : Output {
val configPath: String
val versionId: String
}

operator fun DescribeIosVersions.invoke() {
if (versionId.isBlank()) throw FlankConfigurationError("Argument VERSION_ID must be specified.")
logLn(IosCatalog.describeSoftwareVersion(IosArgs.loadOrDefault(Paths.get(configPath)).project, versionId))
fetchIosOsVersion(IosArgs.loadOrDefault(Paths.get(configPath)).project)
.find { it.id == versionId }
?.out()
?: throw FlankGeneralError("ERROR: '$versionId' is not a valid OS version")
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
package ftl.presentation.cli.firebase.test.ios.versions

import ftl.api.DeviceModel
import ftl.config.FtlConstants
import ftl.domain.DescribeIosVersions
import ftl.domain.invoke
import ftl.presentation.cli.firebase.test.ios.models.describe.prepareDescription
import ftl.presentation.outputLogger
import ftl.presentation.throwUnknownType
import picocli.CommandLine

@CommandLine.Command(
Expand Down Expand Up @@ -38,5 +42,12 @@ class IosVersionsDescribeCommand :
)
override var versionId: String = ""

override val out = outputLogger {
when (this) {
is DeviceModel.Ios -> prepareDescription()
else -> throwUnknownType()
}
}

override fun run() = invoke()
}
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
package ftl.cli.firebase.test.ios.versions

import ftl.client.google.IosCatalog
import ftl.presentation.cli.firebase.test.ios.versions.IosVersionsDescribeCommand
import ftl.run.exception.FlankConfigurationError
import ftl.test.util.TestHelper.getThrowable
import io.mockk.mockkObject
import io.mockk.verify
import org.junit.Assert.assertEquals
import org.junit.Rule
import org.junit.Test
Expand All @@ -16,14 +13,6 @@ class IosVersionsDescribeCommandTest {
@get:Rule
val systemOutRule: SystemOutRule = SystemOutRule().enableLog().muteForSuccessfulTests()

@Test
fun `should execute IosCatalog describeSoftwareVersion when run IosVersionsDescribeCommand`() {
mockkObject(IosCatalog) {
CommandLine(IosVersionsDescribeCommand()).execute("10.3")
verify { IosCatalog.describeSoftwareVersion(any(), any()) }
}
}

@Test(expected = FlankConfigurationError::class)
fun `should throw if version not specified`() {
CommandLine(IosVersionsDescribeCommand()).execute()
Expand Down