Compare commits
2 commits
9d46ca2526
...
ea2d1a86ba
Author | SHA1 | Date | |
---|---|---|---|
ea2d1a86ba | |||
7ac74f73bd |
2 changed files with 19 additions and 5 deletions
|
@ -47,11 +47,16 @@ class Gemini2Test : LocalProperties() {
|
||||||
@DisplayName("Chat Tests")
|
@DisplayName("Chat Tests")
|
||||||
inner class ChatTests {
|
inner class ChatTests {
|
||||||
private val apiKey = getProperty(Gemini2.GEMINI_API_KEY)
|
private val apiKey = getProperty(Gemini2.GEMINI_API_KEY)
|
||||||
private val maxTokens = getProperty(Gemini2.MAX_TOKENS_PROP).toInt()
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@DisableOnCi
|
@DisableOnCi
|
||||||
fun chatHttpRequestInJavascript() {
|
fun chatHttpRequestInJavascript() {
|
||||||
|
val maxTokens = try {
|
||||||
|
getProperty(Gemini2.MAX_TOKENS_PROP).toInt()
|
||||||
|
} catch (_: NumberFormatException) {
|
||||||
|
1024
|
||||||
|
}
|
||||||
|
|
||||||
assertThat(
|
assertThat(
|
||||||
Gemini2.chat(
|
Gemini2.chat(
|
||||||
"javascript function to make a request with XMLHttpRequest, just code",
|
"javascript function to make a request with XMLHttpRequest, just code",
|
||||||
|
|
|
@ -113,21 +113,30 @@ class GoogleSearchTest : LocalProperties() {
|
||||||
@Test
|
@Test
|
||||||
fun `API key should not be empty`() {
|
fun `API key should not be empty`() {
|
||||||
assertFailure { sanitizedSearch("test", "", "apiKey") }
|
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
|
@Test
|
||||||
fun `CSE key should not empty`() {
|
fun `CSE key should not be empty`() {
|
||||||
assertFailure { sanitizedSearch("test", "apiKey", "") }
|
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
|
@Test
|
||||||
fun `Invalid API key should throw exception`() {
|
fun `Invalid API key should throw exception`() {
|
||||||
assertFailure { sanitizedSearch("test", "apiKey", "cssKey") }
|
assertFailure { sanitizedSearch("test", "apiKey", "cseKey") }
|
||||||
.isInstanceOf(ModuleException::class.java)
|
.isInstanceOf(ModuleException::class.java)
|
||||||
.hasMessage("API key not valid. Please pass a valid API key.")
|
.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
|
@Nested
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue