using StellaOps.Feedser.Normalization.Distro;

namespace StellaOps.Feedser.Normalization.Tests;

public sealed class DebianEvrParserTests
{
    [Fact]
    public void ToCanonicalString_RoundTripsExplicitEpoch()
    {
        var parsed = DebianEvr.Parse(" 1:1.2.3-1 ");

        Assert.Equal("1:1.2.3-1", parsed.Original);
        Assert.Equal("1:1.2.3-1", parsed.ToCanonicalString());
    }

    [Fact]
    public void ToCanonicalString_SuppressesZeroEpochWhenMissing()
    {
        var parsed = DebianEvr.Parse("1.2.3-1");

        Assert.Equal("1.2.3-1", parsed.ToCanonicalString());
    }

    [Fact]
    public void ToCanonicalString_HandlesMissingRevision()
    {
        var parsed = DebianEvr.Parse("2:4.5");

        Assert.Equal("2:4.5", parsed.ToCanonicalString());
    }
}
