mirror of
https://github.com/mamoe/mirai.git
synced 2025-01-20 19:09:12 +08:00
Test of rename folder
This commit is contained in:
parent
84b66692e9
commit
1d1a77ff1a
@ -11,6 +11,7 @@ package net.mamoe.console.integrationtest
|
||||
|
||||
import net.mamoe.console.integrationtest.testpoints.DoNothingPoint
|
||||
import net.mamoe.console.integrationtest.testpoints.MCITBSelfAssertions
|
||||
import net.mamoe.console.integrationtest.testpoints.plugin.PluginDataRenameToIdTest
|
||||
import org.junit.jupiter.api.Test
|
||||
import java.io.File
|
||||
import java.lang.management.ManagementFactory
|
||||
@ -32,6 +33,7 @@ class MiraiConsoleIntegrationTestBootstrap {
|
||||
launcher.points = listOf<Any>(
|
||||
DoNothingPoint,
|
||||
MCITBSelfAssertions,
|
||||
PluginDataRenameToIdTest,
|
||||
).asSequence().map { v ->
|
||||
when (v) {
|
||||
is Class<*> -> v
|
||||
|
@ -0,0 +1,82 @@
|
||||
/*
|
||||
* Copyright 2019-2021 Mamoe Technologies and contributors.
|
||||
*
|
||||
* 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证.
|
||||
* Use of this source code is governed by the GNU AGPLv3 license that can be found through the following link.
|
||||
*
|
||||
* https://github.com/mamoe/mirai/blob/dev/LICENSE
|
||||
*/
|
||||
|
||||
package net.mamoe.console.integrationtest.testpoints.plugin
|
||||
|
||||
import net.mamoe.console.integrationtest.AbstractTestPointAsPlugin
|
||||
import net.mamoe.console.integrationtest.assertNotExists
|
||||
import net.mamoe.mirai.console.data.AutoSavePluginConfig
|
||||
import net.mamoe.mirai.console.data.AutoSavePluginData
|
||||
import net.mamoe.mirai.console.data.value
|
||||
import net.mamoe.mirai.console.extension.PluginComponentStorage
|
||||
import net.mamoe.mirai.console.plugin.jvm.JvmPluginDescription
|
||||
import net.mamoe.mirai.console.plugin.jvm.KotlinPlugin
|
||||
import net.mamoe.mirai.utils.touch
|
||||
import java.io.File
|
||||
import kotlin.test.assertEquals
|
||||
|
||||
internal object PluginDataRenameToIdTest : AbstractTestPointAsPlugin() {
|
||||
|
||||
object TestData : AutoSavePluginData("testdata") {
|
||||
public val test: String by value("")
|
||||
}
|
||||
|
||||
object TestConf : AutoSavePluginConfig("testconf") {
|
||||
public val test: String by value("")
|
||||
}
|
||||
|
||||
override fun newPluginDescription(): JvmPluginDescription {
|
||||
return JvmPluginDescription(
|
||||
id = "net.mamoe.testpoint.plugin-data-rename-to-id-test",
|
||||
version = "1.0.0",
|
||||
name = "PluginDataRenameToIdTest",
|
||||
)
|
||||
}
|
||||
|
||||
override fun beforeConsoleStartup() {
|
||||
File("config/PluginDataRenameToIdTest/test.txt").touch()
|
||||
File("config/PluginDataRenameToIdTest/testconf.yml").writeText(
|
||||
"""
|
||||
test: a
|
||||
""".trimIndent()
|
||||
)
|
||||
File("data/PluginDataRenameToIdTest/test.txt").touch()
|
||||
File("data/PluginDataRenameToIdTest/testdata.yml").writeText(
|
||||
"""
|
||||
test: a
|
||||
""".trimIndent()
|
||||
)
|
||||
}
|
||||
|
||||
override fun KotlinPlugin.onLoad0(storage: PluginComponentStorage) {
|
||||
|
||||
File("config/PluginDataRenameToIdTest").assertNotExists()
|
||||
File("data/PluginDataRenameToIdTest").assertNotExists()
|
||||
|
||||
}
|
||||
|
||||
override fun KotlinPlugin.onEnable0() {
|
||||
TestData.reload()
|
||||
TestConf.reload()
|
||||
TestData.save()
|
||||
TestConf.save()
|
||||
|
||||
assertEquals("a", TestConf.test)
|
||||
assertEquals("a", TestData.test)
|
||||
}
|
||||
|
||||
override fun onConsoleStartSuccessfully() {
|
||||
File("config/PluginDataRenameToIdTest/test.txt").assertNotExists()
|
||||
File("data/PluginDataRenameToIdTest/test.txt").assertNotExists()
|
||||
|
||||
|
||||
File("config/PluginDataRenameToIdTest/testconf.yml").assertNotExists()
|
||||
File("data/PluginDataRenameToIdTest/testdata.yml").assertNotExists()
|
||||
}
|
||||
}
|
@ -151,4 +151,9 @@ public fun File.resolveCreateFile(relative: String): File = this.resolve(relativ
|
||||
public fun File.resolveCreateFile(relative: File): File = this.resolve(relative).apply { createFileIfNotExists() }
|
||||
|
||||
public fun File.resolveMkdir(relative: String): File = this.resolve(relative).apply { mkdirs() }
|
||||
public fun File.resolveMkdir(relative: File): File = this.resolve(relative).apply { mkdirs() }
|
||||
public fun File.resolveMkdir(relative: File): File = this.resolve(relative).apply { mkdirs() }
|
||||
|
||||
public fun File.touch(): File = apply {
|
||||
parentFile?.mkdirs()
|
||||
createNewFile()
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user