Compare commits

..

No commits in common. "a32018d60044dd48ee39df72da9340210a1049a6" and "69e9459ebc9639d324ad8974e4a53a90a67d65cc" have entirely different histories.

13 changed files with 74 additions and 99 deletions

View File

@ -14,7 +14,7 @@ import org.ajoberstar.grgit.Status
import java.nio.charset.Charset import java.nio.charset.Charset
import java.nio.charset.StandardCharsets import java.nio.charset.StandardCharsets
final boolean proj_git = grgit != null final boolean proj_git = grgit!=null
final String proj_store = MORNY_CODE_STORE final String proj_store = MORNY_CODE_STORE
final String proj_commit = proj_git ? grgit.head().id : null final String proj_commit = proj_git ? grgit.head().id : null
final String proj_commit_path = MORNY_COMMIT_PATH final String proj_commit_path = MORNY_COMMIT_PATH
@ -23,8 +23,7 @@ if (!proj_git)
println "[MornyBuild] git repository not available for current working space! git version tag will be disabled." println "[MornyBuild] git repository not available for current working space! git version tag will be disabled."
else if (isCleanBuild()) { else if (isCleanBuild()) {
println "git: clean build at ${grgit.head().id}" println "git: clean build at ${grgit.head().id}"
} } else {
else {
final Status status = grgit.status() final Status status = grgit.status()
println "git: non-clean-build" println "git: non-clean-build"
if (!status.unstaged.allChanges.empty) { if (!status.unstaged.allChanges.empty) {
@ -46,8 +45,7 @@ final String proj_version_base = VERSION
final String proj_version_delta = VERSION_DELTA final String proj_version_delta = VERSION_DELTA
final boolean proj_version_use_delta = Boolean.parseBoolean(USE_DELTA) final boolean proj_version_use_delta = Boolean.parseBoolean(USE_DELTA)
final String proj_version = proj_version_base + (proj_version_use_delta ? "-δ${proj_version_delta}" : "") final String proj_version = proj_version_base + (proj_version_use_delta ? "-δ${proj_version_delta}" : "")
final String proj_version_full = proj_version + (proj_git ? final String proj_version_full = proj_version + (proj_git ? "+git.${proj_commit.substring(0, 8)}" + (proj_clean?"":".δ") : "")
"+git.${proj_commit.substring(0, 8)}" + (proj_clean ? "" : ".δ") : "")
final String proj_version_codename = CODENAME final String proj_version_codename = CODENAME
final long proj_code_time = proj_clean ? grgit.head().dateTime.toInstant().toEpochMilli() : System.currentTimeMillis() final long proj_code_time = proj_clean ? grgit.head().dateTime.toInstant().toEpochMilli() : System.currentTimeMillis()
@ -55,7 +53,7 @@ final JavaVersion proj_java = JavaVersion.VERSION_17
final Charset proj_file_encoding = StandardCharsets.UTF_8 final Charset proj_file_encoding = StandardCharsets.UTF_8
final proj_scala_api = 3 final proj_scala_api = 3
//final proj_scala_lib = proj_scala_api+'.4.0-RC1-bin-20230901-89e8dba-NIGHTLY' //final proj_scala_lib = proj_scala_api+'.4.0-RC1-bin-20230901-89e8dba-NIGHTLY'
final proj_scala_lib = proj_scala_api + '.3.1' final proj_scala_lib = proj_scala_api+'.3.1'
String publish_local_url = null String publish_local_url = null
String publish_remote_url = null String publish_remote_url = null
String publish_remote_username = null String publish_remote_username = null
@ -82,7 +80,6 @@ dependencies {
implementation "cc.sukazyo:messiva:${lib_messiva_v}" implementation "cc.sukazyo:messiva:${lib_messiva_v}"
implementation "cc.sukazyo:resource-tools:${lib_resourcetools_v}" implementation "cc.sukazyo:resource-tools:${lib_resourcetools_v}"
testImplementation "cc.sukazyo:resource-tools:${lib_resourcetools_v}"
implementation "com.github.pengrad:java-telegram-bot-api:${lib_javatelegramapi_v}" implementation "com.github.pengrad:java-telegram-bot-api:${lib_javatelegramapi_v}"
implementation "com.squareup.okhttp3:okhttp:${lib_okhttp_v}" implementation "com.squareup.okhttp3:okhttp:${lib_okhttp_v}"
@ -91,8 +88,7 @@ dependencies {
testImplementation "org.scalatest:scalatest_$proj_scala_api:${lib_scalatest_v}" testImplementation "org.scalatest:scalatest_$proj_scala_api:${lib_scalatest_v}"
testImplementation "org.scalatest:scalatest-freespec_$proj_scala_api:${lib_scalatest_v}" testImplementation "org.scalatest:scalatest-freespec_$proj_scala_api:${lib_scalatest_v}"
testRuntimeOnly "org.scala-lang.modules:scala-xml_$proj_scala_api:${lib_scalamodule_xml_v}" testRuntimeOnly "org.scala-lang.modules:scala-xml_$proj_scala_api:${lib_scalamodule_xml_v}"
testRuntimeOnly 'com.vladsch.flexmark:flexmark-all:0.64.6' testRuntimeOnly 'com.vladsch.flexmark:flexmark-all:0.64.6' // for generating HTML report // required by gradle-scalatest plugin
// for generating HTML report // required by gradle-scalatest plugin
} }
@ -159,10 +155,10 @@ buildConfig {
buildConfigField('String', 'VERSION_DELTA', proj_version_use_delta ? "\"${proj_version_delta}\"" : "null") buildConfigField('String', 'VERSION_DELTA', proj_version_use_delta ? "\"${proj_version_delta}\"" : "null")
buildConfigField('String', 'CODENAME', "\"${proj_version_codename}\"") buildConfigField('String', 'CODENAME', "\"${proj_version_codename}\"")
buildConfigField('long', 'CODE_TIMESTAMP', "${proj_code_time}L") buildConfigField('long', 'CODE_TIMESTAMP', "${proj_code_time}L")
buildConfigField('String', 'COMMIT', proj_git ? "\"${proj_commit}\"" : "null") buildConfigField('String', 'COMMIT', proj_git ? "\"${proj_commit}\"" : "null")
buildConfigField('boolean', 'CLEAN_BUILD', "${proj_clean}") buildConfigField('boolean', 'CLEAN_BUILD', "${proj_clean}")
buildConfigField('String', 'CODE_STORE', proj_store == "" ? "null" : "\"${proj_store}\"") buildConfigField('String', 'CODE_STORE', proj_store==""?"null":"\"${proj_store}\"")
buildConfigField('String', 'COMMIT_PATH', proj_commit_path == "" ? "null" : "\"${proj_commit_path}\"") buildConfigField('String', 'COMMIT_PATH', proj_commit_path==""?"null":"\"${proj_commit_path}\"")
} }
@ -204,7 +200,7 @@ void listChanges (Status.Changes listing) {
} }
publishing { publishing {
repositories { repositories{
if (publish_local_url != null) maven { if (publish_local_url != null) maven {
name 'archives' name 'archives'
url publish_local_url url publish_local_url
@ -220,7 +216,7 @@ publishing {
} }
publications { publications {
//noinspection GroovyAssignabilityCheck //noinspection GroovyAssignabilityCheck
main(MavenPublication) { main (MavenPublication) {
//noinspection GroovyAssignabilityCheck //noinspection GroovyAssignabilityCheck
from components.java from components.java
//noinspection GroovyAssignabilityCheck //noinspection GroovyAssignabilityCheck

View File

@ -5,7 +5,7 @@ MORNY_ARCHIVE_NAME = morny-coeur
MORNY_CODE_STORE = https://github.com/Eyre-S/Coeur-Morny-Cono MORNY_CODE_STORE = https://github.com/Eyre-S/Coeur-Morny-Cono
MORNY_COMMIT_PATH = https://github.com/Eyre-S/Coeur-Morny-Cono/commit/%s MORNY_COMMIT_PATH = https://github.com/Eyre-S/Coeur-Morny-Cono/commit/%s
VERSION = 1.2.1-pre1 VERSION = 1.2.0
USE_DELTA = false USE_DELTA = false
VERSION_DELTA = VERSION_DELTA =

View File

@ -67,7 +67,7 @@ class MornyReport (using coeur: MornyCoeur) {
// language=html // language=html
s"""<b>▌Morny Logged in</b> s"""<b>▌Morny Logged in</b>
|-v $getVersionAllFullTagHTML |-v $getVersionAllFullTagHTML
|as user @${coeur.username} |as user ${coeur.username}
| |
|as config fields: |as config fields:
|${sectionConfigFields(coeur.config)}""" |${sectionConfigFields(coeur.config)}"""

Binary file not shown.

Before

Width:  |  Height:  |  Size: 84 KiB

View File

@ -1,14 +1,10 @@
package cc.sukazyo.cono.morny.test package cc.sukazyo.cono.morny.test
import cc.sukazyo.restools.ResourcesPackage
import org.scalatest.freespec.AnyFreeSpec import org.scalatest.freespec.AnyFreeSpec
import org.scalatest.matchers.should import org.scalatest.matchers.should
abstract class MornyTests extends AnyFreeSpec with should.Matchers { abstract class MornyTests extends AnyFreeSpec with should.Matchers {
val assets: ResourcesPackage =
ResourcesPackage(classOf[MornyTests], "assets_morny_tests")
val pending_val = "[not-implemented]" val pending_val = "[not-implemented]"
} }

View File

@ -1,4 +1,4 @@
package cc.sukazyo.cono.morny.test.bot.event package cc.sukazyo.cono.morny.test.cc.sukazyo.cono.morny.bot.event
import cc.sukazyo.cono.morny.bot.event.OnQuestionMarkReply import cc.sukazyo.cono.morny.bot.event.OnQuestionMarkReply
import cc.sukazyo.cono.morny.test.MornyTests import cc.sukazyo.cono.morny.test.MornyTests

View File

@ -0,0 +1,42 @@
package cc.sukazyo.cono.morny.test.cc.sukazyo.cono.morny.daemon
import cc.sukazyo.cono.morny.daemon.MedicationTimer
import cc.sukazyo.cono.morny.test.MornyTests
import cc.sukazyo.cono.morny.util.EpochDateTime.EpochMillis
import org.scalatest.prop.TableDrivenPropertyChecks
import java.time.ZoneOffset
class MedicationTimerTest extends MornyTests with TableDrivenPropertyChecks {
"on calculating next notify time :" - {
val examples = Table(
("current" , "notifyAt" , "useTimezone", "nextNotifyTime"),
(("2023-10-09T23:54:10.000","+8"), Set(1, 5, 19) , "+8" , ("2023-10-10T01:00:00.000","+8")),
(("2022-11-13T13:14:15.000","+2"), Set(7, 19, 21) , "+2" , ("2022-11-13T19:00:00.000","+2")),
(("2022-11-13T13:14:35.000","+8"), Set(7, 19, 21) , "+8" , ("2022-11-13T19:00:00" ,"+8")),
(("2022-11-13T13:14:35.174","+2"), Set(7, 19, 21) , "+2" , ("2022-11-13T19:00:00" ,"+2")),
(("1998-02-01T08:14:35.871","+8"), Set(7, 19, 21) , "+8" , ("1998-02-01T19:00:00" ,"+8")),
(("2022-11-13T00:00:00.000","-1"), Set(7, 19, 21) , "-1" , ("2022-11-13T07:00:00" ,"-1")),
(("2022-11-21T19:00:00.000","+0"), Set(7, 19, 21) , "+0" , ("2022-11-21T21:00:00" ,"+0")),
(("2022-12-31T21:00:00.000","+0"), Set(7, 19, 21) , "+0" , ("2023-01-01T07:00:00" ,"+0")),
(("2125-11-18T23:45:27.062","+0"), Set(7, 19, 21) , "+0" , ("2125-11-19T07:00:00" ,"+0"))
)
forAll (examples) { (current, notifyAt, useTimezone, nextNotifyTime) =>
val _curr = EpochMillis(current)
val _tz = ZoneOffset of useTimezone
val _next = EpochMillis(nextNotifyTime)
s"at time [$_curr], and need to be notify at hours ${notifyAt.mkString(",")} with $_tz :" - {
s"next notify should at time [$_curr]" in {
MedicationTimer.calcNextRoutineTimestamp(_curr, _tz, notifyAt) shouldEqual _next
}
}
}
}
}

View File

@ -1,4 +1,4 @@
package cc.sukazyo.cono.morny.test.data package cc.sukazyo.cono.morny.test.cc.sukazyo.cono.morny.data
import cc.sukazyo.cono.morny.data.BilibiliForms.* import cc.sukazyo.cono.morny.data.BilibiliForms.*
import cc.sukazyo.cono.morny.test.MornyTests import cc.sukazyo.cono.morny.test.MornyTests

View File

@ -1,42 +0,0 @@
package cc.sukazyo.cono.morny.test.daemon
import cc.sukazyo.cono.morny.daemon.MedicationTimer
import cc.sukazyo.cono.morny.test.MornyTests
import cc.sukazyo.cono.morny.util.EpochDateTime.EpochMillis
import org.scalatest.prop.TableDrivenPropertyChecks
import java.time.ZoneOffset
class MedicationTimerTest extends MornyTests with TableDrivenPropertyChecks {
"on calculating next notify time :" - {
val examples = Table(
("current", "notifyAt", "useTimezone", "nextNotifyTime"),
(("2023-10-09T23:54:10.000", "+8"), Set(1, 5, 19), "+8", ("2023-10-10T01:00:00.000", "+8")),
(("2022-11-13T13:14:15.000", "+2"), Set(7, 19, 21), "+2", ("2022-11-13T19:00:00.000", "+2")),
(("2022-11-13T13:14:35.000", "+8"), Set(7, 19, 21), "+8", ("2022-11-13T19:00:00", "+8")),
(("2022-11-13T13:14:35.174", "+2"), Set(7, 19, 21), "+2", ("2022-11-13T19:00:00", "+2")),
(("1998-02-01T08:14:35.871", "+8"), Set(7, 19, 21), "+8", ("1998-02-01T19:00:00", "+8")),
(("2022-11-13T00:00:00.000", "-1"), Set(7, 19, 21), "-1", ("2022-11-13T07:00:00", "-1")),
(("2022-11-21T19:00:00.000", "+0"), Set(7, 19, 21), "+0", ("2022-11-21T21:00:00", "+0")),
(("2022-12-31T21:00:00.000", "+0"), Set(7, 19, 21), "+0", ("2023-01-01T07:00:00", "+0")),
(("2125-11-18T23:45:27.062", "+0"), Set(7, 19, 21), "+0", ("2125-11-19T07:00:00", "+0"))
)
forAll(examples) { (current, notifyAt, useTimezone, nextNotifyTime) =>
val _curr = EpochMillis(current)
val _tz = ZoneOffset of useTimezone
val _next = EpochMillis(nextNotifyTime)
s"at time [$_curr], and need to be notify at hours ${notifyAt.mkString(",")} with $_tz :" - {
s"next notify should at time [$_curr]" in {
MedicationTimer.calcNextRoutineTimestamp(_curr, _tz, notifyAt) shouldEqual _next
}
}
}
}
}

View File

@ -67,23 +67,13 @@ class CommonEncryptTest extends MornyTests with TableDrivenPropertyChecks {
"da39a3ee5e6b4b0d3255bfef95601890afd80709", "da39a3ee5e6b4b0d3255bfef95601890afd80709",
"e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",
"cf83e1357eefb8bdf1542850d66d8007d620e4050b5715dc83f4a921d36ce9ce47d0d13c5d85f2b0ff8318d2877eec2f63b931bd47417a81a538327af927da3e" "cf83e1357eefb8bdf1542850d66d8007d620e4050b5715dc83f4a921d36ce9ce47d0d13c5d85f2b0ff8318d2877eec2f63b931bd47417a81a538327af927da3e"
)), )
( )
"md5.gif", ExampleHashValue(
"f5ca4f935d44b85c431a8bf788c0eaca",
"784cefac7a3699d704756d1a04189d6157405906",
"c0aa75d5345efae1019ca7a56eabc8673499dcee8ab8a8d657fb69f1f929b909",
"2d3123c543aa1745eeae57d2e6c31b6ea07dd2bb14cef2b5939116f9cf705953fb43cf6162c87ee1c7175d1de4af6d9de6f2bc817065cc854b912877848f937b"
))
) )
forAll(examples_binary) { (file, hashes) => forAll(examples_binary) { (file, hashes) =>
val _name = if file == null then "empty file" else s"file $file" val _name = if file == null then "empty file" else s"file $file"
val _data = val _data = if file == null then Array.empty[Byte] else throw NotImplementedError("does not applied file get yet")
if file == null then
Array.empty[Byte]
else
assets.getResource(file).read.readAllBytes
s"while hashing binary $_name :" - { s"while hashing binary $_name :" - {

View File

@ -0,0 +1,9 @@
package cc.sukazyo.cono.morny.test.utils
import cc.sukazyo.cono.morny.test.MornyTests
class FileUtilsTest extends MornyTests {
"while getting the MD5 hash of a file :" in pending
}

View File

@ -1,39 +1,24 @@
package cc.sukazyo.cono.morny.test.utils.tgapi.formatting package cc.sukazyo.cono.morny.test.utils.tgapi.formatting
import cc.sukazyo.cono.morny.test.MornyTests import cc.sukazyo.cono.morny.test.MornyTests
import cc.sukazyo.cono.morny.util.tgapi.formatting.NamingUtils
class NamingUtilsTest extends MornyTests { class NamingUtilsTest extends MornyTests {
"while generating inline query result id :" - { "while generating inline query result id :" - {
import NamingUtils.inlineQueryId
"while not use no data :" - { "while not use no data :" - {
"(different tag) should return different id" in: "(different tag) should return different id" in pending
inlineQueryId("abc") should not equal inlineQueryId("abd") "(same tag) should return the same id" in pending
inlineQueryId("abc") should not equal inlineQueryId("abe")
"(same tag) should return the same id" in:
inlineQueryId("abc") shouldEqual inlineQueryId("abc")
inlineQueryId("[e]vo]wvr'L\"pno[irvP)v]") shouldEqual inlineQueryId("[e]vo]wvr'L\"pno[irvP)v]")
} }
"while use data :" - { "while use data :" - {
"(same tag) with (same data) should return the same id" in: "(same tag) with (same data) should return the same id" in pending
inlineQueryId("random-tag", "123456789") shouldEqual "(same tag) with (different data) should return different id" in pending
inlineQueryId("random-tag", "123456789") "(different tag) with (same data) should return different id" in pending
"(same tag) with (different data) should return different id" in: "change tag and data position should return different id" in pending
inlineQueryId("random-tag", "123456789") should not equal
inlineQueryId("random-tag", "987654321")
"(different tag) with (same data) should return different id" in:
inlineQueryId("random-tag", "123456789") should not equal
inlineQueryId("set-tag", "123456789")
"change tag and data position should return different id" in:
inlineQueryId("tag", "data") should not equal
inlineQueryId("data", "tag")
} }

View File

@ -9,7 +9,6 @@ class TelegramUserInformationTest extends MornyTests with TableDrivenPropertyChe
private val examples_telegram_cdn = Table( private val examples_telegram_cdn = Table(
("username", "cdn"), ("username", "cdn"),
("Eyre_S", "cdn5"), ("Eyre_S", "cdn5"),
("ankarinnie", "cdn1")
) )
forAll(examples_telegram_cdn) ((username, cdn) => s"while user is @$username :" - { forAll(examples_telegram_cdn) ((username, cdn) => s"while user is @$username :" - {