Cleanup.
This commit is contained in:
parent
67f618da71
commit
9f3dc273f0
12 changed files with 49 additions and 51 deletions
|
@ -31,9 +31,11 @@
|
|||
*/
|
||||
package net.thauvin.erik.mobibot.modules
|
||||
|
||||
import net.objecthunter.exp4j.tokenizer.UnknownFunctionOrVariableException
|
||||
import net.thauvin.erik.mobibot.Utils
|
||||
import net.thauvin.erik.mobibot.modules.Calc.Companion.calc
|
||||
import net.thauvin.erik.mobibot.modules.Calc.Companion.calculate
|
||||
import org.assertj.core.api.Assertions.assertThat
|
||||
import org.assertj.core.api.Assertions.assertThatThrownBy
|
||||
import org.testng.annotations.Test
|
||||
|
||||
/**
|
||||
|
@ -41,10 +43,11 @@ import org.testng.annotations.Test
|
|||
*/
|
||||
class CalcTest {
|
||||
@Test
|
||||
fun testCalc() {
|
||||
assertThat(calc("1 + 1")).`as`("calc(1+1)").isEqualTo("1+1 = %s", Utils.bold(2))
|
||||
assertThat(calc("1 -3")).`as`("calc(1 -3)").isEqualTo("1-3 = %s", Utils.bold(-2))
|
||||
assertThat(calc("pi+π+e+φ")).`as`("calc(pi+π+e+φ)").isEqualTo("pi+π+e+φ = %s", Utils.bold("10.62"))
|
||||
assertThat(calc("one + one")).`as`("calc(one + one)").startsWith("No idea.")
|
||||
fun testCalculate() {
|
||||
assertThat(calculate("1 + 1")).`as`("calculate(1+1)").isEqualTo("1+1 = %s", Utils.bold(2))
|
||||
assertThat(calculate("1 -3")).`as`("calculate(1 -3)").isEqualTo("1-3 = %s", Utils.bold(-2))
|
||||
assertThat(calculate("pi+π+e+φ")).`as`("calculate(pi+π+e+φ)").isEqualTo("pi+π+e+φ = %s", Utils.bold("10.62"))
|
||||
assertThatThrownBy { calculate("one + one") }.`as`("calculate(one+one)")
|
||||
.isInstanceOf(UnknownFunctionOrVariableException::class.java)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -64,7 +64,7 @@ class GoogleSearchTest : LocalProperties() {
|
|||
} catch (e: ModuleException) {
|
||||
// Avoid displaying api keys in CI logs
|
||||
if ("true" == System.getenv("CI") && apiKey.isNotBlank() && cseKey.isNotBlank()) {
|
||||
throw ModuleException(e.debugMessage, e.getSanitizedMessage(apiKey, cseKey))
|
||||
throw ModuleException(e.debugMessage, e.getSanitizedMessage(apiKey, cseKey), e)
|
||||
} else {
|
||||
throw e
|
||||
}
|
||||
|
|
|
@ -31,7 +31,7 @@
|
|||
*/
|
||||
package net.thauvin.erik.mobibot.modules
|
||||
|
||||
import net.thauvin.erik.mobibot.modules.Lookup.Companion.lookup
|
||||
import net.thauvin.erik.mobibot.modules.Lookup.Companion.nslookup
|
||||
import net.thauvin.erik.mobibot.modules.Lookup.Companion.whois
|
||||
import org.assertj.core.api.Assertions.assertThat
|
||||
import org.testng.annotations.Test
|
||||
|
@ -43,7 +43,7 @@ class LookupTest {
|
|||
@Test
|
||||
@Throws(Exception::class)
|
||||
fun testLookup() {
|
||||
val result = lookup("apple.com")
|
||||
val result = nslookup("apple.com")
|
||||
assertThat(result).`as`("lookup(apple.com)").contains("17.253.144.10")
|
||||
}
|
||||
|
||||
|
|
|
@ -62,7 +62,7 @@ class StockQuoteTest : LocalProperties() {
|
|||
} catch (e: ModuleException) {
|
||||
// Avoid displaying api keys in CI logs
|
||||
if ("true" == System.getenv("CI") && apiKey.isNotBlank()) {
|
||||
throw ModuleException(e.debugMessage, e.getSanitizedMessage(apiKey))
|
||||
throw ModuleException(e.debugMessage, e.getSanitizedMessage(apiKey), e)
|
||||
} else {
|
||||
throw e
|
||||
}
|
||||
|
|
|
@ -47,7 +47,7 @@ class TwitterTest : LocalProperties() {
|
|||
val ciName = System.getenv("CI_NAME")
|
||||
return ciName ?: try {
|
||||
InetAddress.getLocalHost().hostName
|
||||
} catch (e: UnknownHostException) {
|
||||
} catch (ignore: UnknownHostException) {
|
||||
"Unknown Host"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -32,7 +32,7 @@
|
|||
package net.thauvin.erik.mobibot.modules
|
||||
|
||||
import net.thauvin.erik.mobibot.Utils
|
||||
import net.thauvin.erik.mobibot.modules.WorldTime.Companion.worldTime
|
||||
import net.thauvin.erik.mobibot.modules.WorldTime.Companion.time
|
||||
import org.assertj.core.api.Assertions.assertThat
|
||||
import org.testng.annotations.Test
|
||||
|
||||
|
@ -41,9 +41,9 @@ import org.testng.annotations.Test
|
|||
*/
|
||||
class WordTimeTest {
|
||||
@Test
|
||||
fun testWorldTime() {
|
||||
assertThat(worldTime("PST").msg).`as`("PST").endsWith(Utils.bold("Los Angeles"))
|
||||
assertThat(worldTime("BLAH").isError).`as`("BLAH").isTrue
|
||||
assertThat(worldTime("BEATS").msg).`as`("BEATS").contains("@")
|
||||
fun testTime() {
|
||||
assertThat(time("PST").msg).`as`("PST").endsWith(Utils.bold("Los Angeles"))
|
||||
assertThat(time("BLAH").isError).`as`("BLAH").isTrue
|
||||
assertThat(time("BEATS").msg).`as`("BEATS").contains("@")
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue