Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DYN-7826: pm compatibility bug fix #15651

Merged
merged 1 commit into from
Nov 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/DynamoPackages/PackageManagerSearchElement.cs
Original file line number Diff line number Diff line change
Expand Up @@ -369,13 +369,13 @@ internal static bool IsVersionCompatible(Greg.Responses.Compatibility compatibil
bool isListedInVersions = compatibility.versions?.Contains(version.ToString()) ?? false;

// Parse min and max values, if provided, and check for valid range
bool isWithinMinMax = true;
bool isWithinMinMax = false;
if (!string.IsNullOrEmpty(compatibility.min) || !string.IsNullOrEmpty(compatibility.max))
{
Version minVersion = VersionUtilities.Parse(compatibility.min);
Version maxVersion = VersionUtilities.Parse(compatibility.max);

// if max is null, try to parse based on wildcard symantics
// if max is null, try to parse based on wildcard semantics
if(maxVersion == null)
{
maxVersion = VersionUtilities.WildCardParse(compatibility.max);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1027,6 +1027,32 @@ public void TestComputeVersionNoDynamoCompatibility()
Assert.IsNull(resultNoCompatibility, "Expected unknown compatibility (null) when no compatibility information is provided.");
}

[Test]
public void TestComputeVersionSingleCompatibility()
{
// Arrange
var hostOnlyCompatibilityMatrix = new List<Greg.Responses.Compatibility>
{
new Greg.Responses.Compatibility { name = "dynamo", versions = new List<string> { "3.2.2" } }
};

var compatibleDynamoVersion = new Version("3.2.2"); // Compatible with Dynamo 3.2.2
var incompatibleDynamoVersion = new Version("3.4.0"); // Incompatible with Dynamo 3.4.0

// Act
// Case 1: Single Dynamo version, compatible
var resultDynamoCompatibility = PackageManagerSearchElement.CalculateCompatibility(
hostOnlyCompatibilityMatrix, compatibleDynamoVersion, compatibilityMap);

// Case 2: Single Dynamo version, incompatible
var resultNoDynamoCompatibility = PackageManagerSearchElement.CalculateCompatibility(
hostOnlyCompatibilityMatrix, incompatibleDynamoVersion, compatibilityMap);

// Assert
Assert.IsTrue(resultDynamoCompatibility, "Expected compatible with matching Dynamo versions.");
Assert.IsFalse(resultNoDynamoCompatibility, "Expected incompatible with mismatched Dynamo versions.");
}

[Test]
public void HostCompatibilityFiltersExclusivity()
{
Expand Down Expand Up @@ -1162,6 +1188,20 @@ public void IsVersionCompatible_ExactVersionInList_ReturnsTrue()
Assert.IsTrue(result, "Expected compatibility to be true when version is in the list.");
}

[Test]
public void IsVersionCompatible_NoCompatibleVersion_ReturnsFalse()
{
var compatibility = new Greg.Responses.Compatibility
{
versions = new List<string> { "2.1.0", "2.3.0" }
};
Version version = new Version("2.2.0");

bool result = PackageManagerSearchElement.IsVersionCompatible(compatibility, version);

Assert.IsFalse(result, "Expected compatibility to be false when version is not in the list.");
}

[Test]
public void IsVersionCompatible_MinOnly_ReturnsTrueForCompatibleVersion()
{
Expand Down
Loading