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

Add failing test for bug in GetLatestMaskedVersion #77

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
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
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
<NeutralLanguage>en-US</NeutralLanguage>
<Copyright>Copyright © Octopus Deploy 2017</Copyright>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<!-- nuget packages with security warnings should not break the build -->
<WarningsNotAsErrors>CS0618,NU1901,NU1902,NU1903</WarningsNotAsErrors>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\Octopus.Versioning\Octopus.Versioning.csproj" />
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using System.Linq;
using NUnit.Framework;
using Octopus.Versioning.Octopus;
using Octopus.Versioning.Semver;
Expand Down Expand Up @@ -220,5 +221,34 @@ public void GetLatestVersionMask(string version, string latestVersion, string ex
Assert.AreEqual(expected, latestMaskedVersionNewImplementationPrefix?.ToString());
}
}

[Test]
public void GetLatestMaskedVersionShouldNotBeOrderDependent()
{
var mask = OctopusVersionMaskParser.Parse("0.0.7+branchA.c.c.i");
var versionParser = new OctopusVersionParser();

var versions = new[]
{
"0.0.7+branchA.1",
"0.0.7+branchA",
"0.0.6+branchA",
"0.0.5-beta.2",
"0.0.5-beta.1",
"0.0.4-beta",
"0.0.3",
"0.0.1",
"0.0.2"
}.Select(v => (IVersion)versionParser.Parse(v))
.ToList();

// This is the correct answer that we are looking for
Assert.AreEqual("0.0.7+branchA.1", mask.GetLatestMaskedVersion(versions)!.ToString());

// Now the real test; it should still return the same result even if the versions are not in the correct order
var reversedVersions = versions.ToList();
reversedVersions.Reverse();
Assert.AreEqual("0.0.7+branchA.1", mask.GetLatestMaskedVersion(reversedVersions)!.ToString());
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This currently returns 0.0.7+branchA instead of A.1

}
}
}
Loading