Skip to content

Commit

Permalink
tests: Ensure semver build metadata is ignored
Browse files Browse the repository at this point in the history
According to the Semantic Versioning specification, build metadata must
be ignored for version comparisions, so add some explicit tests for this
scenario to `TestGetNewReleaseType()`.

Signed-off-by: James O. D. Hunt <james.o.hunt@intel.com>
  • Loading branch information
jodh-intel committed Nov 12, 2020
1 parent df99deb commit 8fbf9aa
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions cli/release_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -458,6 +458,21 @@ func TestGetNewReleaseType(t *testing.T) {
}

data := []testData{
// Check build metadata (ignored for version comparisons)
{"2.0.0+build", "2.0.0", true, ""},
{"2.0.0+build-1", "2.0.0+build-2", true, ""},
{"1.12.0+build", "1.12.0", true, ""},

{"2.0.0-rc3+foo", "2.0.0", false, "major"},
{"2.0.0-rc3+foo", "2.0.0-rc4", false, "pre-release"},
{"1.12.0+foo", "1.13.0", false, "minor"},

{"1.12.0+build", "2.0.0", false, "major"},
{"1.12.0+build", "1.13.0", false, "minor"},
{"1.12.0-rc2+build", "1.12.1", false, "patch"},
{"1.12.0-rc2+build", "1.12.1-foo", false, "patch pre-release"},
{"1.12.0-rc4+wibble", "1.12.0", false, "major"},

{"2.0.0-alpha3", "1.0.0", true, ""},
{"1.0.0", "1.0.0", true, ""},
{"2.0.0", "1.0.0", true, ""},
Expand Down

0 comments on commit 8fbf9aa

Please sign in to comment.