File tree Expand file tree Collapse file tree
main/kotlin/ftl/environment
test/kotlin/ftl/cli/firebase/test Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11package ftl.environment
22
33import com.google.api.services.testing.model.Locale
4+ import ftl.util.FlankGeneralError
45
56fun 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" )
Original file line number Diff line number Diff line change 11package ftl.cli.firebase.test.android.configuration
22
33import ftl.android.AndroidCatalog
4+ import ftl.test.util.TestHelper.getThrowable
45import ftl.util.FlankConfigurationError
56import io.mockk.mockkObject
67import 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}
Original file line number Diff line number Diff line change @@ -2,6 +2,7 @@ package ftl.cli.firebase.test.ios.configuration
22
33import ftl.ios.IosCatalog
44import ftl.test.util.TestHelper
5+ import ftl.test.util.TestHelper.getThrowable
56import ftl.util.FlankConfigurationError
67import io.mockk.mockkObject
78import 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}
You can’t perform that action at this time.
0 commit comments