Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
juraj-hrivnak committed Feb 2, 2025
1 parent 7771af7 commit dff5c87
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 39 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -61,15 +61,13 @@ class ExportProfileBuilder(
this.lockFile = exportingScope.lockFile
this.configFile = exportingScope.configFile

// Don't mutate this class
val builderCopy = ExportProfileBuilder(name, fileExtension, requiresPlatform, builder, rules)
this.rules = emptySequence()
this.apply(builder)

debug { println("Building [${builderCopy.name} profile]") }
debug { println("[${builderCopy.name} profile] has ${builderCopy.rules.toList().size} rule(s)") }
debug { println("Building [${this.name} profile]") }
debug { println("[${this.name} profile] has ${this.rules.toList().size} rule(s)") }

return ExportProfile(
builderCopy.name, builderCopy.fileExtension, builderCopy.rules.toList(), builderCopy.requiresPlatform
)
return ExportProfile(this.name, this.fileExtension, this.rules.toList(), this.requiresPlatform)
}

// -- AFTER BUILD --
Expand Down
1 change: 0 additions & 1 deletion src/commonMain/kotlin/teksturepako/pakku/cli/cmd/Diff.kt
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,6 @@ class Diff : CliktCommand()
/** We only care about projects, which previously also existed **/
val oldProject = allOldProjects.find { it.isAlmostTheSameAs(newProject) } ?: continue

/** If the project files are not identical, means that files have changed **/
if (oldProject.files == newProject.files) continue

/** On multi-loader modpacks, the mod might have been added for another loader, causing the
Expand Down
6 changes: 3 additions & 3 deletions src/commonTest/kotlin/teksturepako/pakku/PakkuTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,14 @@ import kotlin.io.path.*
import kotlin.test.AfterTest
import kotlin.test.BeforeTest

open class PakkuTest
open class PakkuTest(protected open val teardown: Boolean = true)
{
private var testName: String = ""

protected open suspend fun `set-up`()
{
}

protected open val teardown = true

protected fun testFile(vararg path: String): Path
{
return Path(workingPath, *path)
Expand All @@ -44,6 +42,8 @@ open class PakkuTest
pakku {
developmentMode()
}

debugMode = true

testName = this::class.simpleName ?: generatePakkuId()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,33 @@ import kotlin.io.path.pathString
import kotlin.test.Test
import kotlin.test.assertNotNull

class CfModpackModelTest : PakkuTest()
class CfModpackModelTest : PakkuTest(teardown = false)
{
private val modpackName = "CurseForgeProfileTestModpack"

private val greeneryCfId = 574029
private val greeneryCfFileId = 5913357

private val greeneryProject = Project(
type = ProjectType.MOD,
id = mutableMapOf(CurseForge.serialName to greeneryCfId.toString()),
name = mutableMapOf(CurseForge.serialName to "Greenery\uD83C\uDF3F"),
slug = mutableMapOf(CurseForge.serialName to "greenery"),
files = mutableSetOf(
ProjectFile(
type = CurseForge.serialName,
fileName = "Greenery-1.12.2-7.0.jar",
mcVersions = mutableListOf("1.12.2", "1.12.1", "1.12"),
loaders = mutableListOf("forge"),
id = greeneryCfFileId.toString(),
parentId = greeneryCfId.toString(),
)
)
)

private val mcVersion = "1.12.2"
private val forgeVersion = "xxx.xxx.xxx"

override suspend fun `set-up`()
{
val lockFile = LockFile(
Expand Down Expand Up @@ -52,31 +77,6 @@ class CfModpackModelTest : PakkuTest()
}
}

private val modpackName = "CurseForgeProfileTestModpack"

private val greeneryCfId = 574029
private val greeneryCfFileId = 5913357

private val greeneryProject = Project(
type = ProjectType.MOD,
id = mutableMapOf(CurseForge.serialName to greeneryCfId.toString()),
name = mutableMapOf(CurseForge.serialName to "Greenery\uD83C\uDF3F"),
slug = mutableMapOf(CurseForge.serialName to "greenery"),
files = mutableSetOf(
ProjectFile(
type = CurseForge.serialName,
fileName = "Greenery-1.12.2-7.0.jar",
mcVersions = mutableListOf("1.12.2", "1.12.1", "1.12"),
loaders = mutableListOf("forge"),
id = greeneryCfFileId.toString(),
parentId = greeneryCfId.toString(),
)
)
)

private val mcVersion = "1.12.2"
private val forgeVersion = "xxx.xxx.xxx"

@Test
fun `test cf modpack model in cache`()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,6 @@ import teksturepako.pakku.io.readPathTextOrNull
import kotlin.io.path.Path
import kotlin.io.path.pathString
import kotlin.test.Test
import kotlin.test.assertContains
import kotlin.test.assertEquals
import kotlin.test.assertNotNull

class MrModpackModelTest : PakkuTest()
Expand Down

0 comments on commit dff5c87

Please sign in to comment.