Skip to content

Commit

Permalink
#37: Fix ValidationPackageIndex.IdentityEquals not respecting semve…
Browse files Browse the repository at this point in the history
…r suffixes
  • Loading branch information
kMutagene committed Jun 21, 2024
1 parent a39258f commit 1379710
Show file tree
Hide file tree
Showing 5 changed files with 99 additions and 1 deletion.
6 changes: 6 additions & 0 deletions PackageStagingArea.sln
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ Project("{6EC3EE1D-3C4E-46DD-8F32-0CC8E7565705}") = "StagingAreaTests", "Staging
EndProject
Project("{6EC3EE1D-3C4E-46DD-8F32-0CC8E7565705}") = "IndexTests", "tests\IndexTests\IndexTests.fsproj", "{FA7524A5-3A92-4E33-8E28-726BA2E615D2}"
EndProject
Project("{6EC3EE1D-3C4E-46DD-8F32-0CC8E7565705}") = "AVPRCI", "src\AVPRCI\AVPRCI.fsproj", "{C1929D1B-10BD-4826-B2C5-413369B5FE2E}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand All @@ -27,6 +29,10 @@ Global
{FA7524A5-3A92-4E33-8E28-726BA2E615D2}.Debug|Any CPU.Build.0 = Debug|Any CPU
{FA7524A5-3A92-4E33-8E28-726BA2E615D2}.Release|Any CPU.ActiveCfg = Release|Any CPU
{FA7524A5-3A92-4E33-8E28-726BA2E615D2}.Release|Any CPU.Build.0 = Release|Any CPU
{C1929D1B-10BD-4826-B2C5-413369B5FE2E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{C1929D1B-10BD-4826-B2C5-413369B5FE2E}.Debug|Any CPU.Build.0 = Debug|Any CPU
{C1929D1B-10BD-4826-B2C5-413369B5FE2E}.Release|Any CPU.ActiveCfg = Release|Any CPU
{C1929D1B-10BD-4826-B2C5-413369B5FE2E}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
2 changes: 1 addition & 1 deletion src/AVPRIndex/AVPRIndex.fsproj
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
<RepositoryType>git</RepositoryType>
<PackageReleaseNotes>$([System.IO.File]::ReadAllText("$(MSBuildProjectDirectory)/RELEASE_NOTES.md"))</PackageReleaseNotes>
<PackageReadmeFile>README.md</PackageReadmeFile>
<PackageVersion>0.2.0</PackageVersion>
<PackageVersion>0.2.1</PackageVersion>
</PropertyGroup>

<ItemGroup>
Expand Down
2 changes: 2 additions & 0 deletions src/AVPRIndex/Domain.fs
Original file line number Diff line number Diff line change
Expand Up @@ -333,6 +333,8 @@ module Domain =
&& first.Metadata.MajorVersion = second.Metadata.MajorVersion
&& first.Metadata.MinorVersion = second.Metadata.MinorVersion
&& first.Metadata.PatchVersion = second.Metadata.PatchVersion
&& first.Metadata.PreReleaseVersionSuffix = second.Metadata.PreReleaseVersionSuffix
&& first.Metadata.BuildMetadataVersionSuffix = second.Metadata.BuildMetadataVersionSuffix

/// returns true when the two packages have the same content hash
static member contentEquals (first: ValidationPackageIndex) (second: ValidationPackageIndex) =
Expand Down
4 changes: 4 additions & 0 deletions src/AVPRIndex/RELEASE_NOTES.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## v0.2.1

Fix `ValidationPackageIndex.IdentityEquals` not respecting semver suffixes

## v0.2.0

- Add `SemVer` type model for a full semantic version representation including PreRelease and Build metadata with parsing and formatting functions
Expand Down
86 changes: 86 additions & 0 deletions tests/IndexTests/ValidationPackageIndexTests.fs
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,92 @@ It does it very fast, it does it very swell.
let actual = ValidationPackageIndex.CommentFrontmatter.validFullFrontmatter |> ValidationPackageIndex.getSemanticVersionString
Assert.Equal(SemVer.Strings.fixtureFile, actual)

[<Fact>]
let ``identityEquals returns true for identical versions``() =
Assert.True(
ValidationPackageIndex.identityEquals
ValidationPackageIndex.CommentFrontmatter.validMandatoryFrontmatter
ValidationPackageIndex.CommentFrontmatter.validMandatoryFrontmatter
)

[<Fact>]
let ``identityEquals returns false for non-identical versions``() =
Assert.False(
ValidationPackageIndex.identityEquals
ValidationPackageIndex.CommentFrontmatter.validMandatoryFrontmatter
ValidationPackageIndex.CommentFrontmatter.validFullFrontmatter
)

[<Fact>]
let ``identityEquals returns false for same version with suffixes``() =
let a = ValidationPackageIndex.create(
repoPath = "",
fileName = "",
lastUpdated = testDate,
contentHash = "",
metadata = ValidationPackageMetadata.create(
name = "",
majorVersion = 1,
minorVersion = 0,
patchVersion = 0,
summary = "",
description = "",
PreReleaseVersionSuffix = "some",
BuildMetadataVersionSuffix = "suffix"
)
)
let b = ValidationPackageIndex.create(
repoPath = "",
fileName = "",
lastUpdated = testDate,
contentHash = "",
metadata = ValidationPackageMetadata.create(
name = "",
majorVersion = 1,
minorVersion = 0,
patchVersion = 0,
summary = "",
description = ""
)
)
Assert.False(ValidationPackageIndex.identityEquals a b)

[<Fact>]
let ``identityEquals returns true for identical version with suffixes``() =
let a = ValidationPackageIndex.create(
repoPath = "",
fileName = "",
lastUpdated = testDate,
contentHash = "",
metadata = ValidationPackageMetadata.create(
name = "",
majorVersion = 1,
minorVersion = 0,
patchVersion = 0,
summary = "",
description = "",
PreReleaseVersionSuffix = "some",
BuildMetadataVersionSuffix = "suffix"
)
)
let b = ValidationPackageIndex.create(
repoPath = "",
fileName = "",
lastUpdated = testDate,
contentHash = "",
metadata = ValidationPackageMetadata.create(
name = "",
majorVersion = 1,
minorVersion = 0,
patchVersion = 0,
summary = "",
description = "",
PreReleaseVersionSuffix = "some",
BuildMetadataVersionSuffix = "suffix"
)
)
Assert.True(ValidationPackageIndex.identityEquals a b)

module CommentFrontmatterIO =

open System.IO
Expand Down

0 comments on commit 1379710

Please sign in to comment.