mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2026-10-22 16:17:44 +00:00
First Test MV
This commit is contained in:
1 parent
42b8db4856
commit
68b842d5dc
24 files changed
+237
-128
No files matched your search
@@ -1,7 +1,9 @@
|
||||
package art.arcane.iris.core;
|
||||
|
||||
import art.arcane.iris.core.nms.datapack.DataVersion;
|
||||
import art.arcane.iris.core.nms.datapack.v1217.DataFixerV1217;
|
||||
import art.arcane.volmlib.util.collection.KList;
|
||||
import art.arcane.volmlib.util.json.JSONObject;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.Assume;
|
||||
@@ -41,7 +43,6 @@ public class IrisDatapackCompilerTest {
|
||||
packRoots,
|
||||
new KList<File>().qadd(datapackRoot.toFile()),
|
||||
new DataFixerV1217(),
|
||||
107,
|
||||
false
|
||||
);
|
||||
|
||||
@@ -72,7 +73,6 @@ public class IrisDatapackCompilerTest {
|
||||
List.of(packRoot.toFile()),
|
||||
new KList<File>().qadd(datapackRoot.toFile()),
|
||||
new DataFixerV1217(),
|
||||
107,
|
||||
false
|
||||
);
|
||||
|
||||
@@ -99,6 +99,33 @@ public class IrisDatapackCompilerTest {
|
||||
IrisDatapackCompiler.collectPackRoots(dataDirectory, serverRoot));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void packMcmetaSpansEverySupportedRuntimeFormat() throws Exception {
|
||||
Path datapackRoot = temporaryFolder.newFolder("mcmeta-datapack").toPath();
|
||||
|
||||
IrisDatapackCompiler.compile(
|
||||
List.of(),
|
||||
new KList<File>().qadd(datapackRoot.toFile()),
|
||||
new DataFixerV1217(),
|
||||
false
|
||||
);
|
||||
|
||||
JSONObject pack = new JSONObject(Files.readString(datapackRoot.resolve("pack.mcmeta"), StandardCharsets.UTF_8))
|
||||
.getJSONObject("pack");
|
||||
int minFormat = pack.getInt("min_format");
|
||||
int maxFormat = pack.getInt("max_format");
|
||||
|
||||
assertEquals(101, minFormat);
|
||||
assertEquals(107, maxFormat);
|
||||
assertEquals(maxFormat, pack.getInt("pack_format"));
|
||||
|
||||
// One artifact serves both runtimes: each supported DataVersion's format must be in range.
|
||||
assertTrue(minFormat <= DataVersion.V26_1_2.getPackFormat()
|
||||
&& DataVersion.V26_1_2.getPackFormat() <= maxFormat);
|
||||
assertTrue(minFormat <= DataVersion.V26_2.getPackFormat()
|
||||
&& DataVersion.V26_2.getPackFormat() <= maxFormat);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void compilingNoPacksPublishesCleanEmptyDatapack() throws Exception {
|
||||
Path datapackRoot = temporaryFolder.newFolder("empty-datapack").toPath();
|
||||
@@ -110,7 +137,6 @@ public class IrisDatapackCompilerTest {
|
||||
List.of(),
|
||||
new KList<File>().qadd(datapackRoot.toFile()),
|
||||
new DataFixerV1217(),
|
||||
107,
|
||||
false
|
||||
);
|
||||
|
||||
|
||||
@@ -57,6 +57,30 @@ public class MinecraftVersionTest {
|
||||
assertEquals(0, version.patch());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void parsesThreePartNewSchemeVersion() {
|
||||
MinecraftVersion version = MinecraftVersion.fromBukkitVersion("26.1.2-R0.1-SNAPSHOT");
|
||||
assertEquals("26.1.2", version.value());
|
||||
assertEquals(26, version.major());
|
||||
assertEquals(1, version.minor());
|
||||
assertEquals(2, version.patch());
|
||||
assertTrue(version.isSameRelease(26, 1, 2));
|
||||
assertFalse(version.isSameRelease(26, 2, 0));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void detectsThreePartVersionFromDecoratedVersion() {
|
||||
Server server = mock(Server.class);
|
||||
doReturn("git-Paper-74 (MC: 26.1.2)").when(server).getVersion();
|
||||
doReturn("26.1.2-R0.1-SNAPSHOT").when(server).getBukkitVersion();
|
||||
|
||||
MinecraftVersion version = MinecraftVersion.detect(server);
|
||||
assertEquals("26.1.2", version.value());
|
||||
assertEquals(26, version.major());
|
||||
assertEquals(1, version.minor());
|
||||
assertEquals(2, version.patch());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void comparesMajorBeforeMinor() {
|
||||
MinecraftVersion version = MinecraftVersion.fromBukkitVersion("26.2-R0.1-SNAPSHOT");
|
||||
|
||||
@@ -14,6 +14,13 @@ public class NmsBindingSelectorTest {
|
||||
assertEquals("v26_2_R1", NmsBindingSelector.select(version));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void selectsSharedRevisionFor2612() {
|
||||
MinecraftVersion version = MinecraftVersion.fromBukkitVersion("26.1.2-R0.1-SNAPSHOT");
|
||||
|
||||
assertEquals("v26_2_R1", NmsBindingSelector.select(version));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void rejectsUnsupportedVersionsWithoutProbingAnotherRevision() {
|
||||
MinecraftVersion version = MinecraftVersion.fromBukkitVersion("26.3-R0.1-SNAPSHOT");
|
||||
@@ -24,6 +31,16 @@ public class NmsBindingSelectorTest {
|
||||
assertTrue(failure.getMessage().contains("26.3"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void rejectsBasePatchOfSupportedMinorLine() {
|
||||
MinecraftVersion version = MinecraftVersion.fromBukkitVersion("26.1-R0.1-SNAPSHOT");
|
||||
|
||||
IllegalStateException failure = assertThrows(IllegalStateException.class,
|
||||
() -> NmsBindingSelector.select(version));
|
||||
|
||||
assertTrue(failure.getMessage().contains("26.1"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void rejectsMissingVersionDetection() {
|
||||
assertThrows(IllegalStateException.class, () -> NmsBindingSelector.select(null));
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
package art.arcane.iris.core.nms.datapack;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertSame;
|
||||
|
||||
public class DataVersionTest {
|
||||
@Test
|
||||
public void latestRemainsNewestSupportedRelease() {
|
||||
assertSame(DataVersion.V26_2, DataVersion.getLatest());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void packFormatsMatchServerVersionJson() {
|
||||
assertEquals(101, DataVersion.V26_1_2.getPackFormat());
|
||||
assertEquals(107, DataVersion.V26_2.getPackFormat());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void minSupportedPackFormatIsTheOldestSupportedRuntime() {
|
||||
assertEquals(101, DataVersion.minSupportedPackFormat());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void bothSupportedReleasesShareAFixer() {
|
||||
assertNotNull(DataVersion.V26_1_2.get());
|
||||
assertNotNull(DataVersion.V26_2.get());
|
||||
assertSame(DataVersion.V26_1_2.get().getClass(), DataVersion.V26_2.get().getClass());
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user