diff --git a/morny-coeur/src/test/scala/cc/sukazyo/cono/morny/test/MornyTests.scala b/morny-coeur/src/test/scala/cc/sukazyo/cono/morny/test/MornyTests.scala index dbbe88a..36c3700 100644 --- a/morny-coeur/src/test/scala/cc/sukazyo/cono/morny/test/MornyTests.scala +++ b/morny-coeur/src/test/scala/cc/sukazyo/cono/morny/test/MornyTests.scala @@ -9,6 +9,4 @@ abstract class MornyTests extends AnyFreeSpec with should.Matchers { val pack: ResourcePackage = ResourcePackage.get("assets_morny_tests") val assets: ResourceDirectory = pack.getDirectory("assets_morny_tests") - val pending_val = "[not-implemented]" - } diff --git a/morny-coeur/src/test/scala/cc/sukazyo/cono/morny/test/utils/tgapi/InputCommandTest.scala b/morny-coeur/src/test/scala/cc/sukazyo/cono/morny/test/utils/tgapi/InputCommandTest.scala deleted file mode 100644 index 06fe1d2..0000000 --- a/morny-coeur/src/test/scala/cc/sukazyo/cono/morny/test/utils/tgapi/InputCommandTest.scala +++ /dev/null @@ -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 } - - } - - } - - } - -} diff --git a/morny-coeur/src/test/scala/cc/sukazyo/cono/morny/test/utils/tgapi/formatting/TelegramFormatterTest.scala b/morny-coeur/src/test/scala/cc/sukazyo/cono/morny/test/utils/tgapi/formatting/TelegramFormatterTest.scala deleted file mode 100644 index 1fbd912..0000000 --- a/morny-coeur/src/test/scala/cc/sukazyo/cono/morny/test/utils/tgapi/formatting/TelegramFormatterTest.scala +++ /dev/null @@ -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 - -} diff --git a/morny-core/src/test/scala/cc/sukazyo/cono/morny/MornyCoreTests.scala b/morny-core/src/test/scala/cc/sukazyo/cono/morny/MornyCoreTests.scala new file mode 100644 index 0000000..49537c5 --- /dev/null +++ b/morny-core/src/test/scala/cc/sukazyo/cono/morny/MornyCoreTests.scala @@ -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 diff --git a/morny-coeur/src/test/scala/cc/sukazyo/cono/morny/test/utils/CommonFormatTest.scala b/morny-core/src/test/scala/cc/sukazyo/cono/morny/utils/TestCommonFormat.scala similarity index 83% rename from morny-coeur/src/test/scala/cc/sukazyo/cono/morny/test/utils/CommonFormatTest.scala rename to morny-core/src/test/scala/cc/sukazyo/cono/morny/utils/TestCommonFormat.scala index 33dac4f..b39dde6 100644 --- a/morny-coeur/src/test/scala/cc/sukazyo/cono/morny/test/utils/CommonFormatTest.scala +++ b/morny-core/src/test/scala/cc/sukazyo/cono/morny/utils/TestCommonFormat.scala @@ -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 org.scalatest.prop.TableDrivenPropertyChecks -class CommonFormatTest extends MornyTests with TableDrivenPropertyChecks { +class TestCommonFormat extends MornyCoreTests { "while using #formatDate :" - { diff --git a/morny-coeur/src/test/scala/cc/sukazyo/cono/morny/test/utils/schedule/CronTaskTest.scala b/morny-core/src/test/scala/cc/sukazyo/cono/morny/utils/schedule/TestCronTask.scala similarity index 91% rename from morny-coeur/src/test/scala/cc/sukazyo/cono/morny/test/utils/schedule/CronTaskTest.scala rename to morny-core/src/test/scala/cc/sukazyo/cono/morny/utils/schedule/TestCronTask.scala index 4ace71c..f504fa5 100644 --- a/morny-coeur/src/test/scala/cc/sukazyo/cono/morny/test/utils/schedule/CronTaskTest.scala +++ b/morny-core/src/test/scala/cc/sukazyo/cono/morny/utils/schedule/TestCronTask.scala @@ -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.CommonFormat.formatDate +import cc.sukazyo.cono.morny.MornyCoreTests import com.cronutils.builder.CronBuilder import com.cronutils.model.definition.CronDefinitionBuilder 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.temporal.ChronoUnit -class CronTaskTest extends MornyTests { +class TestCronTask extends MornyCoreTests { "cron task works fine" taggedAs Slow in { diff --git a/morny-coeur/src/test/scala/cc/sukazyo/cono/morny/test/utils/schedule/IntervalsTest.scala b/morny-core/src/test/scala/cc/sukazyo/cono/morny/utils/schedule/TestIntervalTask.scala similarity index 82% rename from morny-coeur/src/test/scala/cc/sukazyo/cono/morny/test/utils/schedule/IntervalsTest.scala rename to morny-core/src/test/scala/cc/sukazyo/cono/morny/utils/schedule/TestIntervalTask.scala index da49874..e699812 100644 --- a/morny-coeur/src/test/scala/cc/sukazyo/cono/morny/test/utils/schedule/IntervalsTest.scala +++ b/morny-core/src/test/scala/cc/sukazyo/cono/morny/utils/schedule/TestIntervalTask.scala @@ -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.MornyCoreTests 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 { val scheduler = Scheduler() diff --git a/morny-coeur/src/test/scala/cc/sukazyo/cono/morny/test/utils/schedule/TaskBasicTest.scala b/morny-core/src/test/scala/cc/sukazyo/cono/morny/utils/schedule/TestTaskBasics.scala similarity index 90% rename from morny-coeur/src/test/scala/cc/sukazyo/cono/morny/test/utils/schedule/TaskBasicTest.scala rename to morny-core/src/test/scala/cc/sukazyo/cono/morny/utils/schedule/TestTaskBasics.scala index ccf4e02..95fcfed 100644 --- a/morny-coeur/src/test/scala/cc/sukazyo/cono/morny/test/utils/schedule/TaskBasicTest.scala +++ b/morny-core/src/test/scala/cc/sukazyo/cono/morny/utils/schedule/TestTaskBasics.scala @@ -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.MornyCoreTests import org.scalatest.tagobjects.Slow -class TaskBasicTest extends MornyTests { +class TestTaskBasics extends MornyCoreTests { "while comparing tasks :" - { diff --git a/morny-coeur/src/test/scala/cc/sukazyo/cono/morny/test/utils/schedule/SchedulerTest.scala b/morny-core/src/test/scala/cc/sukazyo/cono/morny/utils/schedule/TestTaskScheduler.scala similarity index 91% rename from morny-coeur/src/test/scala/cc/sukazyo/cono/morny/test/utils/schedule/SchedulerTest.scala rename to morny-core/src/test/scala/cc/sukazyo/cono/morny/utils/schedule/TestTaskScheduler.scala index c0383b0..e2ee942 100644 --- a/morny-coeur/src/test/scala/cc/sukazyo/cono/morny/test/utils/schedule/SchedulerTest.scala +++ b/morny-core/src/test/scala/cc/sukazyo/cono/morny/utils/schedule/TestTaskScheduler.scala @@ -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.MornyCoreTests import org.scalatest.tagobjects.Slow import scala.collection.mutable -class SchedulerTest extends MornyTests { +class TestTaskScheduler extends MornyCoreTests { "While executing tasks using scheduler :" - { diff --git a/morny-coeur/src/test/scala/cc/sukazyo/cono/morny/test/utils/var_text/VarTextTest.scala b/morny-core/src/test/scala/cc/sukazyo/cono/morny/utils/var_text/TestVarText.scala similarity index 82% rename from morny-coeur/src/test/scala/cc/sukazyo/cono/morny/test/utils/var_text/VarTextTest.scala rename to morny-core/src/test/scala/cc/sukazyo/cono/morny/utils/var_text/TestVarText.scala index 569d75a..6ee77f8 100644 --- a/morny-coeur/src/test/scala/cc/sukazyo/cono/morny/test/utils/var_text/VarTextTest.scala +++ b/morny-core/src/test/scala/cc/sukazyo/cono/morny/utils/var_text/TestVarText.scala @@ -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.MornyCoreTests -class VarTextTest extends MornyTests { +class TestVarText extends MornyCoreTests { "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") diff --git a/morny-coeur/src/test/resources/assets_morny_tests/md5.gif b/morny-system-lib/src/test/resources/assets/morny-system/tests/md5.gif similarity index 100% rename from morny-coeur/src/test/resources/assets_morny_tests/md5.gif rename to morny-system-lib/src/test/resources/assets/morny-system/tests/md5.gif diff --git a/morny-system-lib/src/test/scala/cc/sukazyo/cono/morny/system/MornySystemTests.scala b/morny-system-lib/src/test/scala/cc/sukazyo/cono/morny/system/MornySystemTests.scala new file mode 100644 index 0000000..3100b64 --- /dev/null +++ b/morny-system-lib/src/test/scala/cc/sukazyo/cono/morny/system/MornySystemTests.scala @@ -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) + + } + +} diff --git a/morny-system-lib/src/test/scala/cc/sukazyo/cono/morny/system/telegram_api/command/TestInputCommand.scala b/morny-system-lib/src/test/scala/cc/sukazyo/cono/morny/system/telegram_api/command/TestInputCommand.scala new file mode 100644 index 0000000..35447da --- /dev/null +++ b/morny-system-lib/src/test/scala/cc/sukazyo/cono/morny/system/telegram_api/command/TestInputCommand.scala @@ -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" + } + + } + + } + +} diff --git a/morny-coeur/src/test/scala/cc/sukazyo/cono/morny/test/utils/tgapi/formatting/NamingUtilsTest.scala b/morny-system-lib/src/test/scala/cc/sukazyo/cono/morny/system/telegram_api/formatting/TestNamingUtils.scala similarity index 85% rename from morny-coeur/src/test/scala/cc/sukazyo/cono/morny/test/utils/tgapi/formatting/NamingUtilsTest.scala rename to morny-system-lib/src/test/scala/cc/sukazyo/cono/morny/system/telegram_api/formatting/TestNamingUtils.scala index 9f2a498..4eb51db 100644 --- a/morny-coeur/src/test/scala/cc/sukazyo/cono/morny/test/utils/tgapi/formatting/NamingUtilsTest.scala +++ b/morny-system-lib/src/test/scala/cc/sukazyo/cono/morny/system/telegram_api/formatting/TestNamingUtils.scala @@ -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.test.MornyTests +import cc.sukazyo.cono.morny.system.MornySystemTests -class NamingUtilsTest extends MornyTests { +class TestNamingUtils extends MornySystemTests { "while generating inline query result id :" - { diff --git a/morny-system-lib/src/test/scala/cc/sukazyo/cono/morny/system/telegram_api/formatting/TestTelegramFormatter.scala b/morny-system-lib/src/test/scala/cc/sukazyo/cono/morny/system/telegram_api/formatting/TestTelegramFormatter.scala new file mode 100644 index 0000000..92aa13c --- /dev/null +++ b/morny-system-lib/src/test/scala/cc/sukazyo/cono/morny/system/telegram_api/formatting/TestTelegramFormatter.scala @@ -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 + +} diff --git a/morny-coeur/src/test/scala/cc/sukazyo/cono/morny/test/utils/tgapi/formatting/TelegramParseEscapeTest.scala b/morny-system-lib/src/test/scala/cc/sukazyo/cono/morny/system/telegram_api/formatting/TestTelegramParseEscape.scala similarity index 50% rename from morny-coeur/src/test/scala/cc/sukazyo/cono/morny/test/utils/tgapi/formatting/TelegramParseEscapeTest.scala rename to morny-system-lib/src/test/scala/cc/sukazyo/cono/morny/system/telegram_api/formatting/TestTelegramParseEscape.scala index 89d2429..7bbb0b1 100644 --- a/morny-coeur/src/test/scala/cc/sukazyo/cono/morny/test/utils/tgapi/formatting/TelegramParseEscapeTest.scala +++ b/morny-system-lib/src/test/scala/cc/sukazyo/cono/morny/system/telegram_api/formatting/TestTelegramParseEscape.scala @@ -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 :" - { @@ -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{')}}" "& must be escaped" in: - h("a & b") shouldEqual "a & b" + h("a & b") shouldEqual "a & b" "< and > must be escaped" in: - h("") shouldEqual "<data-error>" + h("") shouldEqual "<data-error>" "& and < and > must all be escaped" in: - h(" && ") shouldEqual "<some-a> && <some-b>" + h(" && ") shouldEqual "<some-a> && <some-b>" "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: - h(any_other) shouldEqual any_other + h(any_other) shouldEqual any_other } diff --git a/morny-coeur/src/test/scala/cc/sukazyo/cono/morny/test/utils/tgapi/formatting/TelegramUserInformationTest.scala b/morny-system-lib/src/test/scala/cc/sukazyo/cono/morny/system/telegram_api/formatting/TestTelegramUserInformation.scala similarity index 56% rename from morny-coeur/src/test/scala/cc/sukazyo/cono/morny/test/utils/tgapi/formatting/TelegramUserInformationTest.scala rename to morny-system-lib/src/test/scala/cc/sukazyo/cono/morny/system/telegram_api/formatting/TestTelegramUserInformation.scala index cabffc6..0b020d9 100644 --- a/morny-coeur/src/test/scala/cc/sukazyo/cono/morny/test/utils/tgapi/formatting/TelegramUserInformationTest.scala +++ b/morny-system-lib/src/test/scala/cc/sukazyo/cono/morny/system/telegram_api/formatting/TestTelegramUserInformation.scala @@ -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.util.SttpPublic -import org.scalatest.prop.TableDrivenPropertyChecks +import cc.sukazyo.cono.morny.system.MornySystemTests import org.scalatest.tagobjects.{Network, Slow} -class TelegramUserInformationTest extends MornyTests with TableDrivenPropertyChecks { +class TestTelegramUserInformation extends MornySystemTests { private val examples_telegram_cdn = Table( ("username", "cdn"), @@ -18,7 +16,7 @@ class TelegramUserInformationTest extends MornyTests with TableDrivenPropertyChe import cc.sukazyo.cono.morny.system.telegram_api.formatting.TelegramUserInformation.* 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: pending diff --git a/morny-coeur/src/test/scala/cc/sukazyo/cono/morny/test/utils/CommonEncryptTest.scala b/morny-system-lib/src/test/scala/cc/sukazyo/cono/morny/system/utils/TestCommonEncrypt.scala similarity index 87% rename from morny-coeur/src/test/scala/cc/sukazyo/cono/morny/test/utils/CommonEncryptTest.scala rename to morny-system-lib/src/test/scala/cc/sukazyo/cono/morny/system/utils/TestCommonEncrypt.scala index e74ad05..cbd61be 100644 --- a/morny-coeur/src/test/scala/cc/sukazyo/cono/morny/test/utils/CommonEncryptTest.scala +++ b/morny-system-lib/src/test/scala/cc/sukazyo/cono/morny/system/utils/TestCommonEncrypt.scala @@ -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 org.scalatest.prop.TableDrivenPropertyChecks +import cc.sukazyo.cono.morny.system.MornySystemTests +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 :" - { - import cc.sukazyo.cono.morny.system.utils.CommonEncrypt.{MD5, SHA1, SHA256, SHA512} - import cc.sukazyo.cono.morny.system.utils.ConvertByteHex.toHex - val examples = Table( ( "text", @@ -52,7 +50,6 @@ class CommonEncryptTest extends MornyTests with TableDrivenPropertyChecks { } } - // todo: binary file source case class ExampleHashValue ( md5: String, sha1: String, @@ -83,7 +80,7 @@ class CommonEncryptTest extends MornyTests with TableDrivenPropertyChecks { if file == null then Array.empty[Byte] else - assets.getFile(file).read.readAllBytes + Assets.root.getFile(file).read.readAllBytes s"while hashing binary $_name :" - { diff --git a/morny-coeur/src/test/scala/cc/sukazyo/cono/morny/test/utils/ConvertByteHexTest.scala b/morny-system-lib/src/test/scala/cc/sukazyo/cono/morny/system/utils/TestConvertByteHex.scala similarity index 75% rename from morny-coeur/src/test/scala/cc/sukazyo/cono/morny/test/utils/ConvertByteHexTest.scala rename to morny-system-lib/src/test/scala/cc/sukazyo/cono/morny/system/utils/TestConvertByteHex.scala index 1b14a78..ce7a2e8 100644 --- a/morny-coeur/src/test/scala/cc/sukazyo/cono/morny/test/utils/ConvertByteHexTest.scala +++ b/morny-system-lib/src/test/scala/cc/sukazyo/cono/morny/system/utils/TestConvertByteHex.scala @@ -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 org.scalatest.prop.TableDrivenPropertyChecks +import cc.sukazyo.cono.morny.system.MornySystemTests +import cc.sukazyo.cono.morny.system.utils.ConvertByteHex.toHex -class ConvertByteHexTest extends MornyTests with TableDrivenPropertyChecks { +class TestConvertByteHex extends MornySystemTests { private val examples_hex = Table( ("byte" , "hex"), @@ -19,7 +19,6 @@ class ConvertByteHexTest extends MornyTests with TableDrivenPropertyChecks { "while using Byte#toHex :" - forAll (examples_hex) ((byte, hex) => { s"byte ($byte) should be hex '$hex''" in { - import cc.sukazyo.cono.morny.system.utils.ConvertByteHex.toHex (byte toHex) shouldEqual hex } }) @@ -37,7 +36,6 @@ class ConvertByteHexTest extends MornyTests with TableDrivenPropertyChecks { "while using Array[Byte]#toHex :" - forAll(examples_hexs) ((bytes, hex) => { s"byte array(${bytes mkString ","}) should be hex string $hex" in { - import cc.sukazyo.cono.morny.system.utils.ConvertByteHex.toHex (bytes toHex) shouldEqual hex } }) diff --git a/morny-coeur/src/test/scala/cc/sukazyo/cono/morny/test/utils/EpochDateTimeTest.scala b/morny-system-lib/src/test/scala/cc/sukazyo/cono/morny/system/utils/TestEpochDateTime.scala similarity index 88% rename from morny-coeur/src/test/scala/cc/sukazyo/cono/morny/test/utils/EpochDateTimeTest.scala rename to morny-system-lib/src/test/scala/cc/sukazyo/cono/morny/system/utils/TestEpochDateTime.scala index 8da78e0..1654d1f 100644 --- a/morny-coeur/src/test/scala/cc/sukazyo/cono/morny/test/utils/EpochDateTimeTest.scala +++ b/morny-system-lib/src/test/scala/cc/sukazyo/cono/morny/system/utils/TestEpochDateTime.scala @@ -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.test.MornyTests -import org.scalatest.prop.TableDrivenPropertyChecks -class EpochDateTimeTest extends MornyTests with TableDrivenPropertyChecks { +class TestEpochDateTime extends MornySystemTests { "while converting to EpochMillis :" - { diff --git a/morny-coeur/src/test/scala/cc/sukazyo/cono/morny/test/utils/UniversalCommandTest.scala b/morny-system-lib/src/test/scala/cc/sukazyo/cono/morny/system/utils/TestUniversalCommand.scala similarity index 92% rename from morny-coeur/src/test/scala/cc/sukazyo/cono/morny/test/utils/UniversalCommandTest.scala rename to morny-system-lib/src/test/scala/cc/sukazyo/cono/morny/system/utils/TestUniversalCommand.scala index f1e4a59..21a9224 100644 --- a/morny-coeur/src/test/scala/cc/sukazyo/cono/morny/test/utils/UniversalCommandTest.scala +++ b/morny-system-lib/src/test/scala/cc/sukazyo/cono/morny/system/utils/TestUniversalCommand.scala @@ -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 org.scalatest.matchers.should.Matchers -import org.scalatest.prop.TableDrivenPropertyChecks +import UniversalCommand as Cmd -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 :" - { - 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 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: Cmd("""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 : Cmd("""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 => s"input with special character ($char) should keep origin like" in { 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 Array(char, "dataset", s"data[$char]contains", "parsed") } diff --git a/project/MornyConfiguration.scala b/project/MornyConfiguration.scala index bee850e..3d5551c 100644 --- a/project/MornyConfiguration.scala +++ b/project/MornyConfiguration.scala @@ -45,7 +45,6 @@ object MornyConfiguration { "com.github.spotbugs" % "spotbugs-annotations" % "4.9.1" % Compile, "cc.sukazyo" % "messiva" % "0.2.0", - "cc.sukazyo" % "resource-tools" % "0.3.1", "cc.sukazyo" % "da4a" % "0.2.0-SNAPSHOT" changing(), "com.github.pengrad" % "java-telegram-bot-api" % "6.2.0", @@ -56,6 +55,8 @@ object MornyConfiguration { "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-freespec" % "3.2.19" % Test, // for test report