1
0
Fork 0
mirror of https://github.com/Luzifer/git-changerelease.git synced 2024-12-20 19:11:17 +00:00
git-changerelease/semver_test.go

31 lines
1.5 KiB
Go

package main
import (
"reflect"
"testing"
)
func TestSemVerParseValid(t *testing.T) {
tests := map[string]semVer{
"1.9.0": semVer{Major: 1, Minor: 9, Patch: 0, PreReleaseInformation: "", MetaData: ""},
"4.9.0": semVer{Major: 4, Minor: 9, Patch: 0, PreReleaseInformation: "", MetaData: ""},
"1068.6.0": semVer{Major: 1068, Minor: 6, Patch: 0, PreReleaseInformation: "", MetaData: ""},
"1.0.0-alpha": semVer{Major: 1, Minor: 0, Patch: 0, PreReleaseInformation: "alpha", MetaData: ""},
"1.0.0-alpha.1": semVer{Major: 1, Minor: 0, Patch: 0, PreReleaseInformation: "alpha.1", MetaData: ""},
"1.0.0-0.3.7": semVer{Major: 1, Minor: 0, Patch: 0, PreReleaseInformation: "0.3.7", MetaData: ""},
"1.0.0-x.7.z.92": semVer{Major: 1, Minor: 0, Patch: 0, PreReleaseInformation: "x.7.z.92", MetaData: ""},
"1.0.0-alpha+001": semVer{Major: 1, Minor: 0, Patch: 0, PreReleaseInformation: "alpha", MetaData: "001"},
"1.0.0+20130313144700": semVer{Major: 1, Minor: 0, Patch: 0, PreReleaseInformation: "", MetaData: "20130313144700"},
"1.0.0-beta+exp.sha.5114f85": semVer{Major: 1, Minor: 0, Patch: 0, PreReleaseInformation: "beta", MetaData: "exp.sha.5114f85"},
}
for version, exp := range tests {
s, e := parseSemVer(version)
if e != nil {
t.Errorf("Parse of version '%s' failed: %s", version, e)
}
if !reflect.DeepEqual(exp, *s) {
t.Errorf("Parse of version '%s' (%#v) did not match expectation: %#v", version, exp, s)
}
}
}