Files
Alphaeus Mote ccfdfd9cf0 fix(versioning): report the version before +metadata, drop the calendar MSI transform
The informational version is now X.Y.Z[.N]+<short commit>, so the reported
version (enrollment, presence, /health, CLI, the watchdog) is everything
before '+'; nothing is cut at '-' any more. No version is still 0.0.0.0.
ToMsiProductVersion (yyyy.MM.dd.HHmm to yy.MM.minutes) is gone: the MSIs
take the four-field version.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-23 20:49:47 -04:00

42 lines
1.4 KiB
C#

using System.Reflection;
using Shared.Infrastructure.Versioning;
using Xunit;
namespace Shared.Tests;
public class BuildVersionTests
{
[Theory]
[InlineData("1.4.0+1a2b3c4", "1.4.0")]
[InlineData("1.4.0.7+1a2b3c4", "1.4.0.7")]
[InlineData("1.4.0.7+1a2b3c4.dirty", "1.4.0.7")]
[InlineData("1.4.0", "1.4.0")]
[InlineData("0.0.0.253+0ce444f", "0.0.0.253")]
// A calendar-era binary still reads (its version had no '+').
[InlineData("2026.10.10.0140", "2026.10.10.0140")]
public void TheReportedVersionDropsOnlyTheBuildMetadata(string informational, string expected)
{
Assert.Equal(expected, BuildVersion.FromInformational(informational));
}
[Theory]
[InlineData(null)]
[InlineData("")]
[InlineData(" ")]
[InlineData("+1a2b3c4")]
public void NoVersionIsTheDevelopmentVersion(string? informational)
{
Assert.Equal(BuildVersion.Development, BuildVersion.FromInformational(informational));
Assert.Equal("0.0.0.0", BuildVersion.Development);
}
[Fact]
public void AnAssemblyWithoutAnInformationalVersionIsTheDevelopmentVersion()
{
Assert.Equal("0.0.0.0", BuildVersion.Resolve(null));
var stamped = BuildVersion.Resolve(typeof(BuildVersion).Assembly);
var informational = typeof(BuildVersion).Assembly.GetCustomAttribute<AssemblyInformationalVersionAttribute>()!.InformationalVersion;
Assert.Equal(informational.Split('+')[0], stamped);
}
}