mirror of
https://github.com/Eyre-S/Coeur-Morny-Cono.git
synced 2025-04-30 01:52:05 +08:00
move tests to their own subprojects, fix InputCommand tests
This commit is contained in:
parent
ea6bf80d48
commit
7b6e3ae9c4
@ -9,6 +9,4 @@ abstract class MornyTests extends AnyFreeSpec with should.Matchers {
|
|||||||
val pack: ResourcePackage = ResourcePackage.get("assets_morny_tests")
|
val pack: ResourcePackage = ResourcePackage.get("assets_morny_tests")
|
||||||
val assets: ResourceDirectory = pack.getDirectory("assets_morny_tests")
|
val assets: ResourceDirectory = pack.getDirectory("assets_morny_tests")
|
||||||
|
|
||||||
val pending_val = "[not-implemented]"
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,79 +0,0 @@
|
|||||||
package cc.sukazyo.cono.morny.test.utils.tgapi
|
|
||||||
|
|
||||||
import cc.sukazyo.cono.morny.system.telegram_api.command.InputCommand
|
|
||||||
import cc.sukazyo.cono.morny.test.MornyTests
|
|
||||||
import org.scalatest.prop.TableDrivenPropertyChecks
|
|
||||||
|
|
||||||
class InputCommandTest extends MornyTests with TableDrivenPropertyChecks {
|
|
||||||
|
|
||||||
"while create new InputCommand :" - {
|
|
||||||
|
|
||||||
val examples = Table[String|Array[String], String, String|Null, Array[String]](
|
|
||||||
(
|
|
||||||
"source",
|
|
||||||
"command",
|
|
||||||
"target",
|
|
||||||
"args"
|
|
||||||
),
|
|
||||||
(
|
|
||||||
"exit@sukazyo_deving_bot",
|
|
||||||
"exit",
|
|
||||||
"sukazyo_deving_bot",
|
|
||||||
Array.empty[String]
|
|
||||||
),
|
|
||||||
(
|
|
||||||
"test@a@b",
|
|
||||||
"test",
|
|
||||||
"a@b",
|
|
||||||
Array.empty[String]
|
|
||||||
),
|
|
||||||
(
|
|
||||||
"test-data@random#user",
|
|
||||||
"test-data",
|
|
||||||
"random#user",
|
|
||||||
Array.empty[String]
|
|
||||||
),
|
|
||||||
(
|
|
||||||
"info@sukazyo_deving_bot stickers.ID_403",
|
|
||||||
"info",
|
|
||||||
"sukazyo_deving_bot",
|
|
||||||
Array("stickers.ID_403")
|
|
||||||
),
|
|
||||||
(
|
|
||||||
"info some extra info",
|
|
||||||
"info",
|
|
||||||
null,
|
|
||||||
Array("some", "extra", "info")
|
|
||||||
),
|
|
||||||
(
|
|
||||||
"",
|
|
||||||
"",
|
|
||||||
null,
|
|
||||||
Array.empty[String]
|
|
||||||
)
|
|
||||||
)
|
|
||||||
|
|
||||||
examples forEvery { (source, command, target, args) =>
|
|
||||||
|
|
||||||
val _source_describe = source match
|
|
||||||
case s: String => s
|
|
||||||
case r: Array[String] => r.mkString
|
|
||||||
s"while input is $_source_describe:" - {
|
|
||||||
|
|
||||||
val _ic: InputCommand = source match
|
|
||||||
case s: String => InputCommand(s)
|
|
||||||
case r: Array[String] => InputCommand(r)
|
|
||||||
|
|
||||||
s"command should be '$command'" in { _ic.command shouldEqual command }
|
|
||||||
s"target should be '$target'" in {_ic.target shouldEqual target}
|
|
||||||
|
|
||||||
"args array should always exists" in { _ic.args shouldNot equal (null) }
|
|
||||||
s"args should parsed to array ${args.mkString}" in { _ic.args shouldEqual args }
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,9 +0,0 @@
|
|||||||
package cc.sukazyo.cono.morny.test.utils.tgapi.formatting
|
|
||||||
|
|
||||||
import cc.sukazyo.cono.morny.test.MornyTests
|
|
||||||
|
|
||||||
class TelegramFormatterTest extends MornyTests {
|
|
||||||
|
|
||||||
"some test" in pending
|
|
||||||
|
|
||||||
}
|
|
@ -0,0 +1,10 @@
|
|||||||
|
package cc.sukazyo.cono.morny
|
||||||
|
|
||||||
|
import org.scalatest.freespec.AnyFreeSpec
|
||||||
|
import org.scalatest.matchers.should.Matchers
|
||||||
|
import org.scalatest.prop.TableDrivenPropertyChecks
|
||||||
|
|
||||||
|
trait MornyCoreTests
|
||||||
|
extends AnyFreeSpec
|
||||||
|
with Matchers
|
||||||
|
with TableDrivenPropertyChecks
|
@ -1,10 +1,9 @@
|
|||||||
package cc.sukazyo.cono.morny.test.utils
|
package cc.sukazyo.cono.morny.utils
|
||||||
|
|
||||||
import cc.sukazyo.cono.morny.test.MornyTests
|
import cc.sukazyo.cono.morny.MornyCoreTests
|
||||||
import cc.sukazyo.cono.morny.util.CommonFormat.{formatDate, formatDuration}
|
import cc.sukazyo.cono.morny.util.CommonFormat.{formatDate, formatDuration}
|
||||||
import org.scalatest.prop.TableDrivenPropertyChecks
|
|
||||||
|
|
||||||
class CommonFormatTest extends MornyTests with TableDrivenPropertyChecks {
|
class TestCommonFormat extends MornyCoreTests {
|
||||||
|
|
||||||
"while using #formatDate :" - {
|
"while using #formatDate :" - {
|
||||||
|
|
@ -1,8 +1,8 @@
|
|||||||
package cc.sukazyo.cono.morny.test.utils.schedule
|
package cc.sukazyo.cono.morny.utils.schedule
|
||||||
|
|
||||||
import cc.sukazyo.cono.morny.test.MornyTests
|
|
||||||
import cc.sukazyo.cono.morny.util.schedule.{CronTask, Scheduler}
|
import cc.sukazyo.cono.morny.util.schedule.{CronTask, Scheduler}
|
||||||
import cc.sukazyo.cono.morny.util.CommonFormat.formatDate
|
import cc.sukazyo.cono.morny.util.CommonFormat.formatDate
|
||||||
|
import cc.sukazyo.cono.morny.MornyCoreTests
|
||||||
import com.cronutils.builder.CronBuilder
|
import com.cronutils.builder.CronBuilder
|
||||||
import com.cronutils.model.definition.CronDefinitionBuilder
|
import com.cronutils.model.definition.CronDefinitionBuilder
|
||||||
import com.cronutils.model.field.expression.FieldExpressionFactory as C
|
import com.cronutils.model.field.expression.FieldExpressionFactory as C
|
||||||
@ -13,7 +13,7 @@ import java.lang.System.currentTimeMillis
|
|||||||
import java.time.{ZonedDateTime, ZoneOffset}
|
import java.time.{ZonedDateTime, ZoneOffset}
|
||||||
import java.time.temporal.ChronoUnit
|
import java.time.temporal.ChronoUnit
|
||||||
|
|
||||||
class CronTaskTest extends MornyTests {
|
class TestCronTask extends MornyCoreTests {
|
||||||
|
|
||||||
"cron task works fine" taggedAs Slow in {
|
"cron task works fine" taggedAs Slow in {
|
||||||
|
|
@ -1,10 +1,10 @@
|
|||||||
package cc.sukazyo.cono.morny.test.utils.schedule
|
package cc.sukazyo.cono.morny.utils.schedule
|
||||||
|
|
||||||
import cc.sukazyo.cono.morny.test.MornyTests
|
|
||||||
import cc.sukazyo.cono.morny.util.schedule.{IntervalWithTimesTask, Scheduler}
|
import cc.sukazyo.cono.morny.util.schedule.{IntervalWithTimesTask, Scheduler}
|
||||||
|
import cc.sukazyo.cono.morny.MornyCoreTests
|
||||||
import org.scalatest.tagobjects.Slow
|
import org.scalatest.tagobjects.Slow
|
||||||
|
|
||||||
class IntervalsTest extends MornyTests {
|
class TestIntervalTask extends MornyCoreTests {
|
||||||
|
|
||||||
"IntervalWithTimesTest should work even scheduler is scheduled to stop" taggedAs Slow in {
|
"IntervalWithTimesTest should work even scheduler is scheduled to stop" taggedAs Slow in {
|
||||||
val scheduler = Scheduler()
|
val scheduler = Scheduler()
|
@ -1,10 +1,10 @@
|
|||||||
package cc.sukazyo.cono.morny.test.utils.schedule
|
package cc.sukazyo.cono.morny.utils.schedule
|
||||||
|
|
||||||
import cc.sukazyo.cono.morny.test.MornyTests
|
|
||||||
import cc.sukazyo.cono.morny.util.schedule.Task
|
import cc.sukazyo.cono.morny.util.schedule.Task
|
||||||
|
import cc.sukazyo.cono.morny.MornyCoreTests
|
||||||
import org.scalatest.tagobjects.Slow
|
import org.scalatest.tagobjects.Slow
|
||||||
|
|
||||||
class TaskBasicTest extends MornyTests {
|
class TestTaskBasics extends MornyCoreTests {
|
||||||
|
|
||||||
"while comparing tasks :" - {
|
"while comparing tasks :" - {
|
||||||
|
|
@ -1,12 +1,12 @@
|
|||||||
package cc.sukazyo.cono.morny.test.utils.schedule
|
package cc.sukazyo.cono.morny.utils.schedule
|
||||||
|
|
||||||
import cc.sukazyo.cono.morny.test.MornyTests
|
|
||||||
import cc.sukazyo.cono.morny.util.schedule.{DelayedTask, Scheduler, Task}
|
import cc.sukazyo.cono.morny.util.schedule.{DelayedTask, Scheduler, Task}
|
||||||
|
import cc.sukazyo.cono.morny.MornyCoreTests
|
||||||
import org.scalatest.tagobjects.Slow
|
import org.scalatest.tagobjects.Slow
|
||||||
|
|
||||||
import scala.collection.mutable
|
import scala.collection.mutable
|
||||||
|
|
||||||
class SchedulerTest extends MornyTests {
|
class TestTaskScheduler extends MornyCoreTests {
|
||||||
|
|
||||||
"While executing tasks using scheduler :" - {
|
"While executing tasks using scheduler :" - {
|
||||||
|
|
@ -1,9 +1,9 @@
|
|||||||
package cc.sukazyo.cono.morny.test.utils.var_text
|
package cc.sukazyo.cono.morny.utils.var_text
|
||||||
|
|
||||||
import cc.sukazyo.cono.morny.test.MornyTests
|
|
||||||
import cc.sukazyo.cono.morny.util.var_text.{VarText, VTNodeLiteral, VTNodeVar}
|
import cc.sukazyo.cono.morny.util.var_text.{VarText, VTNodeLiteral, VTNodeVar}
|
||||||
|
import cc.sukazyo.cono.morny.MornyCoreTests
|
||||||
|
|
||||||
class VarTextTest extends MornyTests {
|
class TestVarText extends MornyCoreTests {
|
||||||
|
|
||||||
"VarText template convertor works." in {
|
"VarText template convertor works." in {
|
||||||
VarText("abcdefg {one_var}{following}it /{escaped}it and this is //double-escape-literal, with a /no-need-to-escape then {{non formatted}}xxx {missing_part")
|
VarText("abcdefg {one_var}{following}it /{escaped}it and this is //double-escape-literal, with a /no-need-to-escape then {{non formatted}}xxx {missing_part")
|
Before Width: | Height: | Size: 84 KiB After Width: | Height: | Size: 84 KiB |
@ -0,0 +1,28 @@
|
|||||||
|
package cc.sukazyo.cono.morny.system
|
||||||
|
|
||||||
|
import cc.sukazyo.restools.{ResourceDirectory, ResourcePackage}
|
||||||
|
import org.scalatest.freespec.AnyFreeSpec
|
||||||
|
import org.scalatest.matchers.should.Matchers
|
||||||
|
import org.scalatest.prop.TableDrivenPropertyChecks
|
||||||
|
|
||||||
|
trait MornySystemTests
|
||||||
|
extends AnyFreeSpec
|
||||||
|
with Matchers
|
||||||
|
with TableDrivenPropertyChecks {
|
||||||
|
|
||||||
|
object Assets {
|
||||||
|
val pack: ResourcePackage = ResourcePackage.get("assets/morny-system/tests")
|
||||||
|
val root: ResourceDirectory = pack.getDirectory("assets/morny-system/tests")
|
||||||
|
}
|
||||||
|
|
||||||
|
object Sttp {
|
||||||
|
import sttp.client3.{basicRequest, Empty, RequestT}
|
||||||
|
import sttp.model.{Header, HeaderNames}
|
||||||
|
|
||||||
|
val testingBasicRequest: RequestT[Empty, Either[String, String], Any] =
|
||||||
|
basicRequest
|
||||||
|
.header(Header(HeaderNames.UserAgent, s"MornySystem / 0.0.0-tests"), true)
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,151 @@
|
|||||||
|
package cc.sukazyo.cono.morny.system.telegram_api.command
|
||||||
|
|
||||||
|
import cc.sukazyo.cono.morny.system.MornySystemTests
|
||||||
|
|
||||||
|
class TestInputCommand extends MornySystemTests {
|
||||||
|
|
||||||
|
"On creating InputCommand" - {
|
||||||
|
|
||||||
|
"using the basic constructor without target field, " - {
|
||||||
|
|
||||||
|
"constructor should be able to receive string array" in {
|
||||||
|
// language=scala 3
|
||||||
|
"""InputCommand(Array("test", "arg1", "arg2"))
|
||||||
|
|""".stripMargin should compile
|
||||||
|
}
|
||||||
|
|
||||||
|
"constructor should be able to receive one string" in {
|
||||||
|
// language=scala 3
|
||||||
|
"""InputCommand("test arg1 arg2")
|
||||||
|
|""".stripMargin should compile
|
||||||
|
}
|
||||||
|
|
||||||
|
"the first args should be the command name" in {
|
||||||
|
val command = InputCommand(Array("test", "arg1", "arg2"))
|
||||||
|
command.command shouldEqual "test"
|
||||||
|
}
|
||||||
|
|
||||||
|
"the rest args should be the command args" in {
|
||||||
|
val command = InputCommand(Array("test", "arg1", "arg2"))
|
||||||
|
command.args shouldEqual Array("arg1", "arg2")
|
||||||
|
}
|
||||||
|
|
||||||
|
"the command args should be an empty array if there is no args" in {
|
||||||
|
val command = InputCommand(Array("test"))
|
||||||
|
command.args shouldEqual Array.empty[String]
|
||||||
|
}
|
||||||
|
|
||||||
|
"the target should always be null" in {
|
||||||
|
val command = InputCommand(Array("test", "arg1", "arg2"))
|
||||||
|
command.target shouldBe null
|
||||||
|
val command2 = InputCommand("test")
|
||||||
|
command2.target shouldBe null
|
||||||
|
}
|
||||||
|
|
||||||
|
"when receiving one single string, it should be split using UniversalCommand format" in {
|
||||||
|
val command = InputCommand("test arg1 arg2")
|
||||||
|
command.command shouldEqual "test"
|
||||||
|
command.args shouldEqual Array("arg1", "arg2")
|
||||||
|
val command2 = InputCommand("""'test a' 'something'""")
|
||||||
|
command2.command shouldEqual "test a"
|
||||||
|
command2.args shouldEqual Array("something")
|
||||||
|
}
|
||||||
|
|
||||||
|
"the prefix '/' should not be removed" in {
|
||||||
|
val command = InputCommand("/test arg1 arg2")
|
||||||
|
command.command shouldEqual "/test"
|
||||||
|
}
|
||||||
|
|
||||||
|
"the '@' symbol in the first args should not be processed as target separator" in {
|
||||||
|
val command = InputCommand(Array("test@something", "arg1", "arg2"))
|
||||||
|
command.command shouldEqual "test@something"
|
||||||
|
command.target shouldBe null
|
||||||
|
}
|
||||||
|
|
||||||
|
def blanks (ic: InputCommand) = {
|
||||||
|
"the command name should be blank string" in {
|
||||||
|
ic.command shouldEqual ""
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
"when using empty array to constructor" - {
|
||||||
|
blanks(InputCommand(Array.empty[String]))
|
||||||
|
}
|
||||||
|
|
||||||
|
"when using blank string to constructor" - {
|
||||||
|
blanks(InputCommand(""))
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
"using the basic constructor with target field, " - {
|
||||||
|
|
||||||
|
"the target should be the second parameter" in {
|
||||||
|
val command = InputCommand(Array("test", "arg1", "arg2"), "target")
|
||||||
|
command.target shouldEqual "target"
|
||||||
|
val command2 = InputCommand("command something", "target name")
|
||||||
|
command2.target shouldEqual "target name"
|
||||||
|
}
|
||||||
|
|
||||||
|
"the first parameter should be processed like the basic constructor" in {
|
||||||
|
val command1 = InputCommand(Array("test", "arg1", "arg2"), "target")
|
||||||
|
command1.command shouldEqual "test"
|
||||||
|
command1.args shouldEqual Array("arg1", "arg2")
|
||||||
|
val command2 = InputCommand("command something", "target name")
|
||||||
|
command2.command shouldEqual "command"
|
||||||
|
command2.args shouldEqual Array("something")
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
"using the telegram constructor, " - {
|
||||||
|
|
||||||
|
"the string formatted command should be accepted" in {
|
||||||
|
// language=scala 3
|
||||||
|
"""InputCommand.inTelegram("test arg1 arg2")
|
||||||
|
|""".stripMargin should compile
|
||||||
|
}
|
||||||
|
|
||||||
|
"the string array formatted command should be accepted" in {
|
||||||
|
// language=scala 3
|
||||||
|
"""InputCommand.inTelegram(Array("test", "arg1", "arg2"))
|
||||||
|
|""".stripMargin should compile
|
||||||
|
}
|
||||||
|
|
||||||
|
"the command should be prased like basic constructor" in {
|
||||||
|
val command = InputCommand.inTelegram("test arg1 arg2")
|
||||||
|
command.command shouldEqual "test"
|
||||||
|
command.args shouldEqual Array("arg1", "arg2")
|
||||||
|
val command2 = InputCommand.inTelegram(Array("test", "arg1", "arg2"))
|
||||||
|
command2.command shouldEqual "test"
|
||||||
|
command2.args shouldEqual Array("arg1", "arg2")
|
||||||
|
}
|
||||||
|
|
||||||
|
"there should be no second parameter as manually defined target" in {
|
||||||
|
// language=scala 3
|
||||||
|
"""InputCommand.inTelegram("test arg1 arg2", "target")
|
||||||
|
|""".stripMargin shouldNot compile
|
||||||
|
}
|
||||||
|
|
||||||
|
"the prefix '/' should not be removed" in {
|
||||||
|
val command = InputCommand.inTelegram("/test arg1 arg2")
|
||||||
|
command.command shouldEqual "/test"
|
||||||
|
}
|
||||||
|
|
||||||
|
"the '@' symbol in the first args should be processed as target separator" in {
|
||||||
|
val command = InputCommand.inTelegram(Array("test@something", "arg1", "arg2"))
|
||||||
|
command.command shouldEqual "test"
|
||||||
|
command.target shouldEqual "something"
|
||||||
|
}
|
||||||
|
|
||||||
|
"only first '@' symbol should be processed as target separator" in {
|
||||||
|
val command = InputCommand.inTelegram(Array("test@something@else", "arg1", "arg2"))
|
||||||
|
command.command shouldEqual "test"
|
||||||
|
command.target shouldBe "something@else"
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -1,9 +1,8 @@
|
|||||||
package cc.sukazyo.cono.morny.test.utils.tgapi.formatting
|
package cc.sukazyo.cono.morny.system.telegram_api.formatting
|
||||||
|
|
||||||
import cc.sukazyo.cono.morny.system.telegram_api.formatting.NamingUtils
|
import cc.sukazyo.cono.morny.system.MornySystemTests
|
||||||
import cc.sukazyo.cono.morny.test.MornyTests
|
|
||||||
|
|
||||||
class NamingUtilsTest extends MornyTests {
|
class TestNamingUtils extends MornySystemTests {
|
||||||
|
|
||||||
"while generating inline query result id :" - {
|
"while generating inline query result id :" - {
|
||||||
|
|
@ -0,0 +1,9 @@
|
|||||||
|
package cc.sukazyo.cono.morny.system.telegram_api.formatting
|
||||||
|
|
||||||
|
import cc.sukazyo.cono.morny.system.MornySystemTests
|
||||||
|
|
||||||
|
class TestTelegramFormatter extends MornySystemTests {
|
||||||
|
|
||||||
|
"TelegramFormatter test" in pending
|
||||||
|
|
||||||
|
}
|
@ -1,8 +1,8 @@
|
|||||||
package cc.sukazyo.cono.morny.test.utils.tgapi.formatting
|
package cc.sukazyo.cono.morny.system.telegram_api.formatting
|
||||||
|
|
||||||
import cc.sukazyo.cono.morny.test.MornyTests
|
import cc.sukazyo.cono.morny.system.MornySystemTests
|
||||||
|
|
||||||
class TelegramParseEscapeTest extends MornyTests {
|
class TestTelegramParseEscape extends MornySystemTests {
|
||||||
|
|
||||||
"while escape HTML document :" - {
|
"while escape HTML document :" - {
|
||||||
|
|
||||||
@ -10,15 +10,15 @@ class TelegramParseEscapeTest extends MornyTests {
|
|||||||
val any_other = "0ir0Q*%_\"ir[0\"#*I%T\"I{EtjpJGI{\")#W*IT}P%*IH#){#NIJB9-/q{$(Jg'9m]q|MH4j0hq}|+($NR{')}}"
|
val any_other = "0ir0Q*%_\"ir[0\"#*I%T\"I{EtjpJGI{\")#W*IT}P%*IH#){#NIJB9-/q{$(Jg'9m]q|MH4j0hq}|+($NR{')}}"
|
||||||
|
|
||||||
"& must be escaped" in:
|
"& must be escaped" in:
|
||||||
h("a & b") shouldEqual "a & b"
|
h("a & b") shouldEqual "a & b"
|
||||||
"< and > must be escaped" in:
|
"< and > must be escaped" in:
|
||||||
h("<data-error>") shouldEqual "<data-error>"
|
h("<data-error>") shouldEqual "<data-error>"
|
||||||
"& and < and > must all be escaped" in:
|
"& and < and > must all be escaped" in:
|
||||||
h("<some-a> && <some-b>") shouldEqual "<some-a> && <some-b>"
|
h("<some-a> && <some-b>") shouldEqual "<some-a> && <some-b>"
|
||||||
"space and count should be kept" in:
|
"space and count should be kept" in:
|
||||||
h("\t<<<< \n") shouldEqual "\t<<<< \n"
|
h("\t<<<< \n") shouldEqual "\t<<<< \n"
|
||||||
"any others should kept origin like" in:
|
"any others should kept origin like" in:
|
||||||
h(any_other) shouldEqual any_other
|
h(any_other) shouldEqual any_other
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
@ -1,11 +1,9 @@
|
|||||||
package cc.sukazyo.cono.morny.test.utils.tgapi.formatting
|
package cc.sukazyo.cono.morny.system.telegram_api.formatting
|
||||||
|
|
||||||
import cc.sukazyo.cono.morny.test.MornyTests
|
import cc.sukazyo.cono.morny.system.MornySystemTests
|
||||||
import cc.sukazyo.cono.morny.util.SttpPublic
|
|
||||||
import org.scalatest.prop.TableDrivenPropertyChecks
|
|
||||||
import org.scalatest.tagobjects.{Network, Slow}
|
import org.scalatest.tagobjects.{Network, Slow}
|
||||||
|
|
||||||
class TelegramUserInformationTest extends MornyTests with TableDrivenPropertyChecks {
|
class TestTelegramUserInformation extends MornySystemTests {
|
||||||
|
|
||||||
private val examples_telegram_cdn = Table(
|
private val examples_telegram_cdn = Table(
|
||||||
("username", "cdn"),
|
("username", "cdn"),
|
||||||
@ -18,7 +16,7 @@ class TelegramUserInformationTest extends MornyTests with TableDrivenPropertyChe
|
|||||||
import cc.sukazyo.cono.morny.system.telegram_api.formatting.TelegramUserInformation.*
|
import cc.sukazyo.cono.morny.system.telegram_api.formatting.TelegramUserInformation.*
|
||||||
|
|
||||||
s"datacenter should be $cdn" taggedAs (Slow, Network) in:
|
s"datacenter should be $cdn" taggedAs (Slow, Network) in:
|
||||||
getDataCenterFromUser(username)(using SttpPublic.mornyBasicRequest) shouldEqual cdn
|
getDataCenterFromUser(username)(using Sttp.testingBasicRequest) shouldEqual cdn
|
||||||
|
|
||||||
"formatted data should as expected" in:
|
"formatted data should as expected" in:
|
||||||
pending
|
pending
|
@ -1,15 +1,13 @@
|
|||||||
package cc.sukazyo.cono.morny.test.utils
|
package cc.sukazyo.cono.morny.system.utils
|
||||||
|
|
||||||
import cc.sukazyo.cono.morny.test.MornyTests
|
import cc.sukazyo.cono.morny.system.MornySystemTests
|
||||||
import org.scalatest.prop.TableDrivenPropertyChecks
|
import cc.sukazyo.cono.morny.system.utils.CommonEncrypt.{MD5, SHA1, SHA256, SHA512}
|
||||||
|
import cc.sukazyo.cono.morny.system.utils.ConvertByteHex.toHex
|
||||||
|
|
||||||
class CommonEncryptTest extends MornyTests with TableDrivenPropertyChecks {
|
class TestCommonEncrypt extends MornySystemTests {
|
||||||
|
|
||||||
"while doing hash :" - {
|
"while doing hash :" - {
|
||||||
|
|
||||||
import cc.sukazyo.cono.morny.system.utils.CommonEncrypt.{MD5, SHA1, SHA256, SHA512}
|
|
||||||
import cc.sukazyo.cono.morny.system.utils.ConvertByteHex.toHex
|
|
||||||
|
|
||||||
val examples = Table(
|
val examples = Table(
|
||||||
(
|
(
|
||||||
"text",
|
"text",
|
||||||
@ -52,7 +50,6 @@ class CommonEncryptTest extends MornyTests with TableDrivenPropertyChecks {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// todo: binary file source
|
|
||||||
case class ExampleHashValue (
|
case class ExampleHashValue (
|
||||||
md5: String,
|
md5: String,
|
||||||
sha1: String,
|
sha1: String,
|
||||||
@ -83,7 +80,7 @@ class CommonEncryptTest extends MornyTests with TableDrivenPropertyChecks {
|
|||||||
if file == null then
|
if file == null then
|
||||||
Array.empty[Byte]
|
Array.empty[Byte]
|
||||||
else
|
else
|
||||||
assets.getFile(file).read.readAllBytes
|
Assets.root.getFile(file).read.readAllBytes
|
||||||
|
|
||||||
s"while hashing binary $_name :" - {
|
s"while hashing binary $_name :" - {
|
||||||
|
|
@ -1,9 +1,9 @@
|
|||||||
package cc.sukazyo.cono.morny.test.utils
|
package cc.sukazyo.cono.morny.system.utils
|
||||||
|
|
||||||
import cc.sukazyo.cono.morny.test.MornyTests
|
import cc.sukazyo.cono.morny.system.MornySystemTests
|
||||||
import org.scalatest.prop.TableDrivenPropertyChecks
|
import cc.sukazyo.cono.morny.system.utils.ConvertByteHex.toHex
|
||||||
|
|
||||||
class ConvertByteHexTest extends MornyTests with TableDrivenPropertyChecks {
|
class TestConvertByteHex extends MornySystemTests {
|
||||||
|
|
||||||
private val examples_hex = Table(
|
private val examples_hex = Table(
|
||||||
("byte" , "hex"),
|
("byte" , "hex"),
|
||||||
@ -19,7 +19,6 @@ class ConvertByteHexTest extends MornyTests with TableDrivenPropertyChecks {
|
|||||||
|
|
||||||
"while using Byte#toHex :" - forAll (examples_hex) ((byte, hex) => {
|
"while using Byte#toHex :" - forAll (examples_hex) ((byte, hex) => {
|
||||||
s"byte ($byte) should be hex '$hex''" in {
|
s"byte ($byte) should be hex '$hex''" in {
|
||||||
import cc.sukazyo.cono.morny.system.utils.ConvertByteHex.toHex
|
|
||||||
(byte toHex) shouldEqual hex
|
(byte toHex) shouldEqual hex
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
@ -37,7 +36,6 @@ class ConvertByteHexTest extends MornyTests with TableDrivenPropertyChecks {
|
|||||||
|
|
||||||
"while using Array[Byte]#toHex :" - forAll(examples_hexs) ((bytes, hex) => {
|
"while using Array[Byte]#toHex :" - forAll(examples_hexs) ((bytes, hex) => {
|
||||||
s"byte array(${bytes mkString ","}) should be hex string $hex" in {
|
s"byte array(${bytes mkString ","}) should be hex string $hex" in {
|
||||||
import cc.sukazyo.cono.morny.system.utils.ConvertByteHex.toHex
|
|
||||||
(bytes toHex) shouldEqual hex
|
(bytes toHex) shouldEqual hex
|
||||||
}
|
}
|
||||||
})
|
})
|
@ -1,10 +1,9 @@
|
|||||||
package cc.sukazyo.cono.morny.test.utils
|
package cc.sukazyo.cono.morny.system.utils
|
||||||
|
|
||||||
|
import cc.sukazyo.cono.morny.system.MornySystemTests
|
||||||
import cc.sukazyo.cono.morny.system.utils.EpochDateTime.{EpochDays, EpochMillis, EpochSeconds}
|
import cc.sukazyo.cono.morny.system.utils.EpochDateTime.{EpochDays, EpochMillis, EpochSeconds}
|
||||||
import cc.sukazyo.cono.morny.test.MornyTests
|
|
||||||
import org.scalatest.prop.TableDrivenPropertyChecks
|
|
||||||
|
|
||||||
class EpochDateTimeTest extends MornyTests with TableDrivenPropertyChecks {
|
class TestEpochDateTime extends MornySystemTests {
|
||||||
|
|
||||||
"while converting to EpochMillis :" - {
|
"while converting to EpochMillis :" - {
|
||||||
|
|
@ -1,14 +1,13 @@
|
|||||||
package cc.sukazyo.cono.morny.test.utils
|
package cc.sukazyo.cono.morny.system.utils
|
||||||
|
|
||||||
import cc.sukazyo.cono.morny.test.MornyTests
|
import UniversalCommand as Cmd
|
||||||
import org.scalatest.matchers.should.Matchers
|
|
||||||
import org.scalatest.prop.TableDrivenPropertyChecks
|
|
||||||
|
|
||||||
class UniversalCommandTest extends MornyTests with Matchers with TableDrivenPropertyChecks {
|
import cc.sukazyo.cono.morny.system.MornySystemTests
|
||||||
|
import cc.sukazyo.cono.morny.system.utils.UniversalCommand.Lossy as Lmd
|
||||||
|
|
||||||
|
class TestUniversalCommand extends MornySystemTests {
|
||||||
|
|
||||||
"while formatting command from String :" - {
|
"while formatting command from String :" - {
|
||||||
import cc.sukazyo.cono.morny.system.utils.UniversalCommand as Cmd
|
|
||||||
import cc.sukazyo.cono.morny.system.utils.UniversalCommand.Lossy as Lmd
|
|
||||||
def whileLossy (info: String): String = "in lossy mode " + info
|
def whileLossy (info: String): String = "in lossy mode " + info
|
||||||
def whileStrict (info: String): String = "in strict mode" + info
|
def whileStrict (info: String): String = "in strict mode" + info
|
||||||
|
|
||||||
@ -25,6 +24,8 @@ class UniversalCommandTest extends MornyTests with Matchers with TableDrivenProp
|
|||||||
"""texts and ascii-spaces in '' should grouped in one arg""" in:
|
"""texts and ascii-spaces in '' should grouped in one arg""" in:
|
||||||
Cmd("""tests 'data set'""") shouldEqual Array("tests", "data set")
|
Cmd("""tests 'data set'""") shouldEqual Array("tests", "data set")
|
||||||
Lmd("""tests 'data set'""") shouldEqual Array("tests", "data set")
|
Lmd("""tests 'data set'""") shouldEqual Array("tests", "data set")
|
||||||
|
Cmd("""'rich command' arg1 arg2""") shouldEqual Array("rich command", "arg1", "arg2")
|
||||||
|
Lmd("""'rich command' arg1 arg2""") shouldEqual Array("rich command", "arg1", "arg2")
|
||||||
"""texts and ascii-spaces in "" should grouped in one arg""" in :
|
"""texts and ascii-spaces in "" should grouped in one arg""" in :
|
||||||
Cmd("""tests "data set"""") shouldEqual Array("tests", "data set")
|
Cmd("""tests "data set"""") shouldEqual Array("tests", "data set")
|
||||||
Lmd("""tests "data set"""") shouldEqual Array("tests", "data set")
|
Lmd("""tests "data set"""") shouldEqual Array("tests", "data set")
|
||||||
@ -112,7 +113,7 @@ class UniversalCommandTest extends MornyTests with Matchers with TableDrivenProp
|
|||||||
forAll(example_special_character) { char =>
|
forAll(example_special_character) { char =>
|
||||||
s"input with special character ($char) should keep origin like" in {
|
s"input with special character ($char) should keep origin like" in {
|
||||||
Cmd(s"$char dataset data[$char]contains parsed") shouldEqual
|
Cmd(s"$char dataset data[$char]contains parsed") shouldEqual
|
||||||
Array(char, "dataset", s"data[$char]contains", "parsed")
|
Array(char, "dataset", s"data[$char]contains", "parsed")
|
||||||
Lmd(s"$char dataset data[$char]contains parsed") shouldEqual
|
Lmd(s"$char dataset data[$char]contains parsed") shouldEqual
|
||||||
Array(char, "dataset", s"data[$char]contains", "parsed")
|
Array(char, "dataset", s"data[$char]contains", "parsed")
|
||||||
}
|
}
|
@ -45,7 +45,6 @@ object MornyConfiguration {
|
|||||||
"com.github.spotbugs" % "spotbugs-annotations" % "4.9.1" % Compile,
|
"com.github.spotbugs" % "spotbugs-annotations" % "4.9.1" % Compile,
|
||||||
|
|
||||||
"cc.sukazyo" % "messiva" % "0.2.0",
|
"cc.sukazyo" % "messiva" % "0.2.0",
|
||||||
"cc.sukazyo" % "resource-tools" % "0.3.1",
|
|
||||||
"cc.sukazyo" % "da4a" % "0.2.0-SNAPSHOT" changing(),
|
"cc.sukazyo" % "da4a" % "0.2.0-SNAPSHOT" changing(),
|
||||||
|
|
||||||
"com.github.pengrad" % "java-telegram-bot-api" % "6.2.0",
|
"com.github.pengrad" % "java-telegram-bot-api" % "6.2.0",
|
||||||
@ -56,6 +55,8 @@ object MornyConfiguration {
|
|||||||
|
|
||||||
"org.jsoup" % "jsoup" % "1.18.3",
|
"org.jsoup" % "jsoup" % "1.18.3",
|
||||||
|
|
||||||
|
"cc.sukazyo" % "resource-tools" % "0.3.2-SNAPSHOT" % Test changing(),
|
||||||
|
|
||||||
"org.scalatest" %% "scalatest" % "3.2.19" % Test,
|
"org.scalatest" %% "scalatest" % "3.2.19" % Test,
|
||||||
"org.scalatest" %% "scalatest-freespec" % "3.2.19" % Test,
|
"org.scalatest" %% "scalatest-freespec" % "3.2.19" % Test,
|
||||||
// for test report
|
// for test report
|
||||||
|
Loading…
Reference in New Issue
Block a user