From a0fdf7562ced5f643fcf9de7fb5fc11d0dc177ce Mon Sep 17 00:00:00 2001 From: Piotr Adamczyk Date: Tue, 11 May 2021 20:28:43 +0200 Subject: [PATCH] refactor: Structural output list provided software --- .../ftl/client/google/ProvidedSoftwareCatalog.kt | 3 --- .../main/kotlin/ftl/domain/ListProvidedSoftware.kt | 7 +++---- .../orientations/AndroidOrientationsListCommand.kt | 1 - .../firebase/test/environment/TestEnvironmentInfo.kt | 1 + .../test/providedsoftware}/ListProvidedSoftware.kt | 2 +- .../providedsoftware/ProvidedSoftwareListCommand.kt | 11 +++++++++++ .../ftl/environment/ListProvidedSoftwareTest.kt | 2 +- 7 files changed, 17 insertions(+), 10 deletions(-) rename test_runner/src/main/kotlin/ftl/{environment/common => presentation/cli/firebase/test/providedsoftware}/ListProvidedSoftware.kt (84%) diff --git a/test_runner/src/main/kotlin/ftl/client/google/ProvidedSoftwareCatalog.kt b/test_runner/src/main/kotlin/ftl/client/google/ProvidedSoftwareCatalog.kt index 626f96fda4..7cd13d36bd 100644 --- a/test_runner/src/main/kotlin/ftl/client/google/ProvidedSoftwareCatalog.kt +++ b/test_runner/src/main/kotlin/ftl/client/google/ProvidedSoftwareCatalog.kt @@ -1,10 +1,7 @@ package ftl.client.google -import ftl.environment.common.toCliTable import ftl.http.executeWithRetry -fun providedSoftwareAsTable() = getProvidedSoftware().toCliTable() - internal fun getProvidedSoftware() = GcTesting.get.testEnvironmentCatalog() .get("provided_software") .executeWithRetry() diff --git a/test_runner/src/main/kotlin/ftl/domain/ListProvidedSoftware.kt b/test_runner/src/main/kotlin/ftl/domain/ListProvidedSoftware.kt index 14208695d3..ef9b62a17a 100644 --- a/test_runner/src/main/kotlin/ftl/domain/ListProvidedSoftware.kt +++ b/test_runner/src/main/kotlin/ftl/domain/ListProvidedSoftware.kt @@ -1,11 +1,10 @@ package ftl.domain -import flank.common.logLn import ftl.api.fetchSoftwareCatalog -import ftl.environment.common.toCliTable +import ftl.presentation.Output -interface ListProvidedSoftware +interface ListProvidedSoftware : Output operator fun ListProvidedSoftware.invoke() { - logLn(fetchSoftwareCatalog().toCliTable()) + fetchSoftwareCatalog().out() } diff --git a/test_runner/src/main/kotlin/ftl/presentation/cli/firebase/test/android/orientations/AndroidOrientationsListCommand.kt b/test_runner/src/main/kotlin/ftl/presentation/cli/firebase/test/android/orientations/AndroidOrientationsListCommand.kt index f9ffd528da..c81c10d947 100644 --- a/test_runner/src/main/kotlin/ftl/presentation/cli/firebase/test/android/orientations/AndroidOrientationsListCommand.kt +++ b/test_runner/src/main/kotlin/ftl/presentation/cli/firebase/test/android/orientations/AndroidOrientationsListCommand.kt @@ -4,7 +4,6 @@ import ftl.api.Orientation import ftl.config.FtlConstants import ftl.domain.ListAndroidOrientations import ftl.domain.invoke -import ftl.environment.common.toCliTable import ftl.presentation.outputLogger import ftl.presentation.throwUnknownType import picocli.CommandLine diff --git a/test_runner/src/main/kotlin/ftl/presentation/cli/firebase/test/environment/TestEnvironmentInfo.kt b/test_runner/src/main/kotlin/ftl/presentation/cli/firebase/test/environment/TestEnvironmentInfo.kt index b19ae4ad82..d99cc09086 100644 --- a/test_runner/src/main/kotlin/ftl/presentation/cli/firebase/test/environment/TestEnvironmentInfo.kt +++ b/test_runner/src/main/kotlin/ftl/presentation/cli/firebase/test/environment/TestEnvironmentInfo.kt @@ -7,6 +7,7 @@ import ftl.environment.ios.toCliTable import ftl.presentation.cli.firebase.test.android.orientations.toCliTable import ftl.presentation.cli.firebase.test.ipblocks.toCliTable import ftl.presentation.cli.firebase.test.locale.toCliTable +import ftl.presentation.cli.firebase.test.providedsoftware.toCliTable fun TestEnvironment.Android.prepareOutputString() = buildString { appendLine(osVersions.toCliTable()) diff --git a/test_runner/src/main/kotlin/ftl/environment/common/ListProvidedSoftware.kt b/test_runner/src/main/kotlin/ftl/presentation/cli/firebase/test/providedsoftware/ListProvidedSoftware.kt similarity index 84% rename from test_runner/src/main/kotlin/ftl/environment/common/ListProvidedSoftware.kt rename to test_runner/src/main/kotlin/ftl/presentation/cli/firebase/test/providedsoftware/ListProvidedSoftware.kt index e0ee96c380..92e48c66e2 100644 --- a/test_runner/src/main/kotlin/ftl/environment/common/ListProvidedSoftware.kt +++ b/test_runner/src/main/kotlin/ftl/presentation/cli/firebase/test/providedsoftware/ListProvidedSoftware.kt @@ -1,4 +1,4 @@ -package ftl.environment.common +package ftl.presentation.cli.firebase.test.providedsoftware import com.google.testing.model.ProvidedSoftwareCatalog import ftl.util.TableColumn diff --git a/test_runner/src/main/kotlin/ftl/presentation/cli/firebase/test/providedsoftware/ProvidedSoftwareListCommand.kt b/test_runner/src/main/kotlin/ftl/presentation/cli/firebase/test/providedsoftware/ProvidedSoftwareListCommand.kt index fd607ccafe..539fc2a30b 100644 --- a/test_runner/src/main/kotlin/ftl/presentation/cli/firebase/test/providedsoftware/ProvidedSoftwareListCommand.kt +++ b/test_runner/src/main/kotlin/ftl/presentation/cli/firebase/test/providedsoftware/ProvidedSoftwareListCommand.kt @@ -1,7 +1,10 @@ package ftl.presentation.cli.firebase.test.providedsoftware +import com.google.testing.model.ProvidedSoftwareCatalog import ftl.domain.ListProvidedSoftware import ftl.domain.invoke +import ftl.presentation.outputLogger +import ftl.presentation.throwUnknownType import picocli.CommandLine @CommandLine.Command( @@ -18,5 +21,13 @@ import picocli.CommandLine class ProvidedSoftwareListCommand : Runnable, ListProvidedSoftware { + override fun run() = invoke() + + override val out = outputLogger { + when (this) { + is ProvidedSoftwareCatalog -> toCliTable() + else -> throwUnknownType() + } + } } diff --git a/test_runner/src/test/kotlin/ftl/environment/ListProvidedSoftwareTest.kt b/test_runner/src/test/kotlin/ftl/environment/ListProvidedSoftwareTest.kt index 1d3d19fd11..38808e1e00 100644 --- a/test_runner/src/test/kotlin/ftl/environment/ListProvidedSoftwareTest.kt +++ b/test_runner/src/test/kotlin/ftl/environment/ListProvidedSoftwareTest.kt @@ -2,7 +2,7 @@ package ftl.environment import com.google.common.truth.Truth.assertThat import ftl.api.fetchSoftwareCatalog -import ftl.environment.common.toCliTable +import ftl.presentation.cli.firebase.test.providedsoftware.toCliTable import ftl.test.util.FlankTestRunner import io.mockk.unmockkAll import org.junit.After