test vmware workstation version checking

This commit is contained in:
Matthew Hooker 2018-01-26 15:58:17 -08:00
parent a4518f8ac8
commit 07421b4433
No known key found for this signature in database
GPG Key ID: 7B5F933D9CE8C6A1
2 changed files with 21 additions and 3 deletions

View File

@ -66,14 +66,17 @@ func workstationVerifyVersion(version string) error {
if err := cmd.Run(); err != nil {
return err
}
return workstationTestVersion(version, stderr.String())
}
func workstationTestVersion(wanted, versionOutput string) error {
versionRe := regexp.MustCompile(`(?i)VMware Workstation (\d+)\.`)
matches := versionRe.FindStringSubmatch(stderr.String())
matches := versionRe.FindStringSubmatch(versionOutput)
if matches == nil {
return fmt.Errorf(
"Could not find VMware WS version in output: %s", stderr.String())
"Could not find VMware WS version in output: %s", wanted)
}
log.Printf("Detected VMware WS version: %s", matches[1])
return compareVersions(matches[1], version, "Workstation")
return compareVersions(matches[1], wanted, "Workstation")
}

View File

@ -0,0 +1,15 @@
// +build !windows
package common
import (
"testing"
)
func TestWorkstationVersion_ws14(t *testing.T) {
input := `VMware Workstation Information:
VMware Workstation 14.1.1 build-7528167 Release`
if err := workstationTestVersion("10", input); err != nil {
t.Fatal(err)
}
}