2
0

MCITBSelfAssertions.kt 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. /*
  2. * Copyright 2019-2021 Mamoe Technologies and contributors.
  3. *
  4. * 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证.
  5. * Use of this source code is governed by the GNU AGPLv3 license that can be found through the following link.
  6. *
  7. * https://github.com/mamoe/mirai/blob/dev/LICENSE
  8. */
  9. package net.mamoe.console.integrationtest.testpoints
  10. import net.mamoe.console.integrationtest.AbstractTestPointAsPlugin
  11. import net.mamoe.mirai.console.plugin.PluginManager
  12. import net.mamoe.mirai.console.plugin.PluginManager.INSTANCE.description
  13. import net.mamoe.mirai.console.plugin.jvm.JvmPluginDescription
  14. import net.mamoe.mirai.console.plugin.jvm.KotlinPlugin
  15. import kotlin.test.*
  16. /*
  17. MCITBSelfAssertions: 用于检查 Integration Test 可以正常加载 AbstractTestPointAsPlugin 与 外部测试插件
  18. */
  19. internal object MCITBSelfAssertions : AbstractTestPointAsPlugin() {
  20. override fun newPluginDescription(): JvmPluginDescription {
  21. return JvmPluginDescription(
  22. id = "net.mamoe.testpoint.mirai-console-self-assertions",
  23. version = "1.0.0",
  24. name = "MCITBSelfAssertions",
  25. )
  26. }
  27. var called = false
  28. override fun KotlinPlugin.onEnable0() {
  29. called = true
  30. assertFails { error("") }
  31. assertTrue { true }
  32. assertFalse { false }
  33. assertFailsWith<InternalError> { throw InternalError("") }
  34. assertEquals("", "")
  35. assertSame(this, this)
  36. }
  37. override fun onConsoleStartSuccessfully() {
  38. assertTrue(called, "Mirai Console IntegrationTestBootstrap Internal Error")
  39. assertTrue("MCITSelfTestPlugin not found") {
  40. PluginManager.plugins.any { it.description.id == "net.mamoe.tester.mirai-console-self-test" }
  41. }
  42. }
  43. }