Add test for invalid CSE key
This commit is contained in:
parent
7ac74f73bd
commit
ea2d1a86ba
1 changed files with 13 additions and 4 deletions
|
@ -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