diff --git a/src/test/kotlin/net/thauvin/erik/mobibot/modules/Gemini2Test.kt b/src/test/kotlin/net/thauvin/erik/mobibot/modules/Gemini2Test.kt index b0b5a28..f5ff2cb 100644 --- a/src/test/kotlin/net/thauvin/erik/mobibot/modules/Gemini2Test.kt +++ b/src/test/kotlin/net/thauvin/erik/mobibot/modules/Gemini2Test.kt @@ -47,11 +47,16 @@ class Gemini2Test : LocalProperties() { @DisplayName("Chat Tests") inner class ChatTests { private val apiKey = getProperty(Gemini2.GEMINI_API_KEY) - private val maxTokens = getProperty(Gemini2.MAX_TOKENS_PROP).toInt() @Test @DisableOnCi fun chatHttpRequestInJavascript() { + val maxTokens = try { + getProperty(Gemini2.MAX_TOKENS_PROP).toInt() + } catch (_: NumberFormatException) { + 1024 + } + assertThat( Gemini2.chat( "javascript function to make a request with XMLHttpRequest, just code", diff --git a/src/test/kotlin/net/thauvin/erik/mobibot/modules/GoogleSearchTest.kt b/src/test/kotlin/net/thauvin/erik/mobibot/modules/GoogleSearchTest.kt index 0edbaa5..a5bce34 100644 --- a/src/test/kotlin/net/thauvin/erik/mobibot/modules/GoogleSearchTest.kt +++ b/src/test/kotlin/net/thauvin/erik/mobibot/modules/GoogleSearchTest.kt @@ -113,21 +113,30 @@ class GoogleSearchTest : LocalProperties() { @Test fun `API key should not be empty`() { assertFailure { sanitizedSearch("test", "", "apiKey") } - .isInstanceOf(ModuleException::class.java).hasNoCause() + .isInstanceOf(ModuleException::class.java) + .hasMessage("${GoogleSearch.SERVICE_NAME} is disabled. The API keys are missing.") } @Test - fun `CSE key should not empty`() { + fun `CSE key should not be empty`() { assertFailure { sanitizedSearch("test", "apiKey", "") } - .isInstanceOf(ModuleException::class.java).hasNoCause() + .isInstanceOf(ModuleException::class.java) + .hasMessage("${GoogleSearch.SERVICE_NAME} is disabled. The API keys are missing.") } @Test fun `Invalid API key should throw exception`() { - assertFailure { sanitizedSearch("test", "apiKey", "cssKey") } + assertFailure { sanitizedSearch("test", "apiKey", "cseKey") } .isInstanceOf(ModuleException::class.java) .hasMessage("API key not valid. Please pass a valid API key.") } + + @Test + fun `Invalid CSE key should throw exception`() { + assertFailure { sanitizedSearch("test", apiKey, "cseKey") } + .isInstanceOf(ModuleException::class.java) + .hasMessage("Request contains an invalid argument.") + } } @Nested