Skip to content

Commit

Permalink
Iteration 1
Browse files Browse the repository at this point in the history
  • Loading branch information
Sloox authored and mergify-bot committed May 10, 2021
1 parent 5f570cd commit e5373cd
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 15 deletions.
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

0 comments on commit e5373cd

Please # to comment.