fix: compare installed package versions semantically

This commit is contained in:
2026-09-05 02:33:59 +08:00
parent 012728ffac
commit 2abf367f36
12 changed files with 270 additions and 36 deletions
+8
View File
@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: a5027bfa9e76434983f82652539bc42a
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,22 @@
{
"name": "ShrinkInstaller.Editor.Tests",
"rootNamespace": "ShrinkSDK.Installer.Tests",
"references": [
"ShrinkInstaller.Editor"
],
"includePlatforms": [
"Editor"
],
"excludePlatforms": [],
"allowUnsafeCode": false,
"overrideReferences": false,
"autoReferenced": false,
"defineConstraints": [
"UNITY_INCLUDE_TESTS"
],
"versionDefines": [],
"noEngineReferences": false,
"optionalUnityReferences": [
"TestAssemblies"
]
}
@@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 00a17f283465481592e764466d9c980d
AssemblyDefinitionImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
+22
View File
@@ -0,0 +1,22 @@
#nullable enable
using NUnit.Framework;
namespace ShrinkSDK.Installer.Tests
{
public sealed class ShrinkPackageVersionTests
{
[TestCase("1.10.0", "1.9.0", ShrinkPackageVersionRelation.Newer)]
[TestCase("2.1.0", "2.1.0", ShrinkPackageVersionRelation.Equal)]
[TestCase("2.0.9", "2.1.0", ShrinkPackageVersionRelation.Older)]
[TestCase("1.0.0", "1.0.0-preview.9", ShrinkPackageVersionRelation.Newer)]
[TestCase("1.0.0-preview.10", "1.0.0-preview.2", ShrinkPackageVersionRelation.Newer)]
[TestCase("1.0.0+build.2", "1.0.0+build.1", ShrinkPackageVersionRelation.Equal)]
[TestCase("git+https://example.invalid/package", "1.0.0", ShrinkPackageVersionRelation.Unknown)]
public void Classify_UsesSemanticVersionOrdering(string installed, string target,
ShrinkPackageVersionRelation expected)
{
Assert.AreEqual(expected, ShrinkPackageVersion.Classify(installed, target));
}
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 9152d73a7f3141429d048528d92b1ecf
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant: