Skip to content

Commit b7daa90

Browse files
committed
When no locale found exit code: 1
1 parent b6967a5 commit b7daa90

3 files changed

Lines changed: 8 additions & 8 deletions

File tree

test_runner/src/main/kotlin/ftl/environment/LocalesDescription.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package ftl.environment
22

33
import com.google.api.services.testing.model.Locale
4+
import ftl.util.FlankGeneralError
45

56
fun List<Locale>.getLocaleDescription(localeId: String) = findLocales(localeId)?.prepareDescription().orErrorMessage(localeId).plus("\n")
67

@@ -23,4 +24,4 @@ private fun StringBuilder.appendTagsToList(locale: Locale) = apply {
2324
locale.tags.filterNotNull().forEach { tag -> appendln("- $tag") }
2425
}.trim().toString()
2526

26-
private fun String?.orErrorMessage(locale: String) = this ?: "ERROR: '$locale' is not a valid locale"
27+
private fun String?.orErrorMessage(locale: String) = this ?: throw FlankGeneralError("ERROR: '$locale' is not a valid locale")

test_runner/src/test/kotlin/ftl/cli/firebase/test/android/configuration/AndroidLocalesDescribeCommandTest.kt

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package ftl.cli.firebase.test.android.configuration
22

33
import ftl.android.AndroidCatalog
4+
import ftl.test.util.TestHelper.getThrowable
45
import ftl.util.FlankConfigurationError
56
import io.mockk.mockkObject
67
import io.mockk.verify
@@ -29,9 +30,7 @@ class AndroidLocalesDescribeCommandTest {
2930

3031
@Test
3132
fun `should return error message if locale not exists`() {
32-
systemOutRule.clearLog()
33-
CommandLine(AndroidLocalesDescribeCommand()).execute("test")
34-
val result = systemOutRule.log.trim()
35-
assertEquals("ERROR: 'test' is not a valid locale", result)
33+
val exception = getThrowable { CommandLine(AndroidLocalesDescribeCommand()).execute("test") }
34+
assertEquals("ERROR: 'test' is not a valid locale", exception.message)
3635
}
3736
}

test_runner/src/test/kotlin/ftl/cli/firebase/test/ios/configuration/IosLocalesDescribeCommandTest.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package ftl.cli.firebase.test.ios.configuration
22

33
import ftl.ios.IosCatalog
44
import ftl.test.util.TestHelper
5+
import ftl.test.util.TestHelper.getThrowable
56
import ftl.util.FlankConfigurationError
67
import io.mockk.mockkObject
78
import io.mockk.verify
@@ -32,9 +33,8 @@ class IosLocalesDescribeCommandTest {
3233

3334
@Test
3435
fun `should return error message if locale not exists`() {
35-
systemOutRule.clearLog()
36-
CommandLine(IosLocalesDescribeCommand()).execute("test", "--config=$simpleFlankPath")
37-
val result = systemOutRule.log.trim()
36+
val exception = getThrowable { CommandLine(IosLocalesDescribeCommand()).execute("test", "--config=$simpleFlankPath") }
37+
val result = exception.message
3838
assertEquals("ERROR: 'test' is not a valid locale", result)
3939
}
4040
}

0 commit comments

Comments
 (0)