Skip to content

Commit

Permalink
Update Tests
Browse files Browse the repository at this point in the history
  • Loading branch information
FirstMegaGame4 committed Oct 23, 2024
1 parent 215085a commit 91e5d3b
Show file tree
Hide file tree
Showing 5 changed files with 116 additions and 5 deletions.
Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.8-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.10-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
Expand Down
2 changes: 1 addition & 1 deletion gradlew
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
# Darwin, MinGW, and NonStop.
#
# (3) This script is generated from the Groovy template
# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
# https://github.com/gradle/gradle/blob/HEAD/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
# within the Gradle project.
#
# You can find Gradle at https://github.com/gradle/gradle/.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ class FabricModJsonTest extends Specification {
buildFile = new File(this.testProjectDir, "build.gradle.kts")
buildFile << """
plugins {
id("fabric-loom").version("1.7-SNAPSHOT")
id("com.mmodding.gradle").version("0.0.9-alpha")
id("fabric-loom").version("1.8-SNAPSHOT")
id("com.mmodding.gradle").version("0.0.10-alpha")
}
version = "0.0.1-test"
Expand All @@ -52,7 +52,7 @@ class FabricModJsonTest extends Specification {
withDependencies {
javaVersion = ">=17"
minecraftVersion = "~1.20.4"
fabricLoaderVersion = "0.15.11"
fabricLoaderVersion = ">=0.15.11-"
fabricApiVersion = "0.97.1+1.20.4"
}
withProvider {
Expand Down
111 changes: 111 additions & 0 deletions src/test/groovy/com/mmodding/gradle/test/QuiltModJsonTest.groovy
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
package com.mmodding.gradle.test

import org.gradle.testkit.runner.GradleRunner
import spock.lang.Specification
import spock.lang.TempDir

import java.nio.file.Files
import java.nio.file.Path;

class QuiltModJsonTest extends Specification {

@TempDir
File testProjectDir

File settingsFile
File buildFile

def setup() {
settingsFile = new File(this.testProjectDir, "settings.gradle.kts")
settingsFile << """
pluginManagement {
repositories {
maven {
name = "Fabric"
url = uri("https://maven.fabricmc.net/")
}
maven {
name = "Quilt"
url = uri("https://maven.quiltmc.org/repository/release")
}
gradlePluginPortal()
}
}
"""
buildFile = new File(this.testProjectDir, "build.gradle.kts")
buildFile << """
plugins {
id("org.quiltmc.loom").version("1.8.+")
id("com.mmodding.gradle").version("0.0.10-alpha")
}
version = "0.0.1-test"
mmodding {
configureQuiltModJson {
name = "Test Mod"
namespace = "test_mod"
group = "com.mmodding.test"
description = "Test Description"
addAuthor("Test Author")
addContributor("Test Contributor")
withContact {
homepage = "https://github.com/MModding/mmodding-gradle"
sources = "https://github.com/MModding/mmodding-gradle"
issues = "https://github.com/MModding/mmodding-gradle/issues"
}
withDependencies {
javaVersion = ">=17"
minecraftVersion = "~1.20.4"
quiltLoaderVersion = ">=0.25.0-"
quiltedFabricApiVersion = ">=1.0.0-"
}
withProvider {
provide("test-mod")
}
withParent("gradle_tests")
withCustom {
withBlock("modmenu") {
withArray("badges") {
addUnique("library")
}
}
}
}
}
dependencies {
minecraft("com.mojang:minecraft:1.20.4")
mappings("org.quiltmc:quilt-mappings:1.20.4+build.3:intermediary-v2")
}
java {
withSourcesJar()
}
"""
}

def "can successfully gather data and nest it"() {
when:
GradleRunner.create()
.withProjectDir(testProjectDir)
.withPluginClasspath()
.withArguments("generateQMJ")
.build()

then:
Path generatedQmjPath = testProjectDir.toPath().resolve("build/generated/generated_resources/quilt.mod.json")
if (Files.exists(generatedQmjPath)) {
String generatedQmj = Files.readString(generatedQmjPath);
if (generatedQmj != "") {
println(generatedQmj)
}
else {
throw new IllegalStateException("Generated QMJ is empty")
}
}
else {
throw new IllegalStateException("Generated QMJ does not exist")
}
}
}

0 comments on commit 91e5d3b

Please sign in to comment.