Skip to content

Commit

Permalink
Fix test code
Browse files Browse the repository at this point in the history
  • Loading branch information
Kieaer committed Oct 13, 2023
1 parent 85936ba commit 81ef0cb
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 58 deletions.
4 changes: 2 additions & 2 deletions src/main/kotlin/essentials/Commands.kt
Original file line number Diff line number Diff line change
Expand Up @@ -804,7 +804,7 @@ class Commands(handler : CommandHandler, isClient : Boolean) {
${bundle["command.info.playtime"]}: ${timeFormat(target.totalPlayTime, "command.info.time")}
${bundle["command.info.playtime.current"]}: ${timeFormat(target.currentPlayTime, "command.info.time.minimal")}
${bundle["command.info.attackclear"]}: ${target.attackModeClear}
${bundle["command.info.pvpwinrate"]}: [green]${target.pvpVictoriesCount}[white]/[scarlet]${target.pvpDefeatCount}[white]([sky]${if (target.pvpVictoriesCount + target.pvpDefeatCount != 0) round(target.pvpVictoriesCount.toDouble() / (target.pvpVictoriesCount + target.pvpDefeatCount) * 100) else "0%"}%[white])
${bundle["command.info.pvpwinrate"]}: [green]${target.pvpVictoriesCount}[white]/[scarlet]${target.pvpDefeatCount}[white]([sky]${if (target.pvpVictoriesCount + target.pvpDefeatCount != 0) round(target.pvpVictoriesCount.toDouble() / (target.pvpVictoriesCount + target.pvpDefeatCount) * 100) else 0}%[white])
${bundle["command.info.joinstacks"]}: ${target.joinStacks}
""".trimIndent()
}
Expand Down Expand Up @@ -1531,7 +1531,7 @@ class Commands(handler : CommandHandler, isClient : Boolean) {
"break" -> DB.Player.blockBreakCount
else -> DB.Player.uuid // dummy
}
DB.Player.slice(type).selectAll().map {
DB.Player.slice(DB.Player.name, DB.Player.uuid, type).selectAll().map {
when(arg[0].lowercase()) {
"time" -> time[Pair(it[DB.Player.name], it[DB.Player.uuid])] = it[DB.Player.totalPlayTime]
"exp" -> exp[Pair(it[DB.Player.name], it[DB.Player.uuid])] = it[DB.Player.exp]
Expand Down
32 changes: 16 additions & 16 deletions src/test/kotlin/ClientCommandTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -25,31 +25,31 @@ import mindustry.game.Gamemode
import mindustry.game.Team
import mindustry.gen.Call
import org.junit.AfterClass
import org.junit.BeforeClass
import org.junit.Test
import org.mindrot.jbcrypt.BCrypt
import java.lang.Thread.sleep

class ClientCommandTest {
companion object {
@AfterClass
@JvmStatic
fun client_shutdown() {
path.child("mods/Essentials").deleteDirectory()
path.child("maps").deleteDirectory()
}
}
private var done = false;
lateinit var playerData: DB.PlayerData

var playerData : DB.PlayerData
@BeforeClass
@JvmStatic
fun setup() {
if (!done) {
loadGame()
loadPlugin()

init {
loadGame()
loadPlugin()
//test.runPost()
val p = newPlayer()
Vars.player = p.first.self()
player = p.first.self()
playerData = p.second

val p = newPlayer()
Vars.player = p.first.self()
player = p.first.self()
playerData = p.second
done = true;
}
}
}

@Test
Expand Down
33 changes: 15 additions & 18 deletions src/test/kotlin/FeatureTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,37 +2,34 @@ import PluginTest.Companion.clientCommand
import PluginTest.Companion.loadGame
import PluginTest.Companion.loadPlugin
import PluginTest.Companion.newPlayer
import PluginTest.Companion.path
import PluginTest.Companion.player
import PluginTest.Companion.setPermission
import essentials.DB
import essentials.Main.Companion.database
import mindustry.Vars
import mindustry.game.Team
import mindustry.gen.Groups
import org.junit.AfterClass
import org.junit.BeforeClass
import org.junit.Test


class FeatureTest {
companion object {
@AfterClass
@JvmStatic
fun shutdown() {
path.child("mods/Essentials").deleteDirectory()
path.child("maps").deleteDirectory()
}
}
private var done = false;
lateinit var playerData: DB.PlayerData

var playerData : DB.PlayerData
@BeforeClass
fun setup() {
if (!done) {
loadGame()
loadPlugin()

init {
loadGame()
loadPlugin()
val p = newPlayer()
Vars.player = p.first.self()
player = p.first.self()
playerData = p.second

val p = newPlayer()
Vars.player = p.first.self()
player = p.first.self()
playerData = p.second
done = true;
}
}

@Test
Expand Down
17 changes: 9 additions & 8 deletions src/test/kotlin/PluginTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -53,13 +53,6 @@ class PluginTest {
val serverCommand : CommandHandler = CommandHandler("")
val clientCommand : CommandHandler = CommandHandler("/")

@AfterClass
@JvmStatic
fun shutdown() {
path.child("mods/Essentials").deleteDirectory()
path.child("maps").deleteDirectory()
}

@Mock
lateinit var mockApplication : Application

Expand All @@ -75,6 +68,8 @@ class PluginTest {
Core.settings.dataDirectory = Fi("")
path = Core.settings.dataDirectory

path.child("maps").deleteDirectory()

path.child("locales").writeString("en")
path.child("version.properties").writeString("modifier=release\ntype=official\nnumber=7\nbuild=custom build")

Expand Down Expand Up @@ -167,6 +162,9 @@ class PluginTest {
}

fun loadPlugin() {
path.child("mods/Essentials").deleteDirectory()

Config.databasePW = "pk1450"
main = Main()

Config.border = true
Expand Down Expand Up @@ -222,7 +220,9 @@ class PluginTest {
return
}
}
player.name(faker.name().lastName())
val name = faker.name().lastName().toCharArray()
name.shuffle()
player.name(name.concatToString())
player.con.uuid = getSaltString()
player.con.usid = getSaltString()
player.set(r.nextInt(300).toFloat(), r.nextInt(500).toFloat())
Expand All @@ -244,6 +244,7 @@ class PluginTest {
return world.tile(random.nextInt(100), random.nextInt(100))
}


fun newPlayer() : Pair<Player, DB.PlayerData> {
val player = createPlayer()
Events.fire(EventType.PlayerJoin(player))
Expand Down
14 changes: 0 additions & 14 deletions src/test/kotlin/SimpleTets.kt

This file was deleted.

0 comments on commit 81ef0cb

Please sign in to comment.