tests: Ensure semver build metadata is ignored

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>
This commit is contained in:
James O. D. Hunt 2020-11-12 10:06:15 +00:00
parent 4024a8274b
commit 2e0bf40adb

View File

@ -458,6 +458,21 @@ func TestGetNewReleaseType(t *testing.T) {
}
data := []testData{
// Check build metadata (ignored for version comparisions)
{"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, ""},