This commit is contained in:
Liang Ding 2018-10-28 09:59:23 +08:00
parent 10d8d65d72
commit d4980a0e4d
No known key found for this signature in database
GPG Key ID: 136F30F901A2231D
1 changed files with 16 additions and 5 deletions

View File

@ -16,9 +16,10 @@ package util
import (
"runtime"
"strconv"
"strings"
"testing"
"github.com/hashicorp/go-version"
)
func TestGetCrossPlatforms(t *testing.T) {
@ -33,17 +34,27 @@ func TestGetAPIPath(t *testing.T) {
apiPath := Go.GetAPIPath()
v := runtime.Version()[2:]
v = v[:3]
verNum, err := strconv.ParseFloat(v, 64)
if 3 < len(v) {
v = v[:4]
} else {
v = v[:3]
}
ver, err := version.NewVersion(v)
if nil != err {
t.Error(err)
return
}
if verNum >= 1.4 {
constraints, err := version.NewConstraint(">= 1.4")
if nil != err {
t.Error(err)
return
}
if constraints.Check(ver) {
if !strings.HasSuffix(apiPath, "src") {
t.Error("api path should end with \"src\"")