mirror of https://github.com/docker/docs.git
Refactor OS Specific code
And introduce Per-OS testing Signed-off-by: Jean-Laurent de Morlhon <jeanlaurent@morlhon.net>
This commit is contained in:
parent
798217fb10
commit
84a40bcc06
|
@ -372,18 +372,7 @@ func (d *Driver) Create() error {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
var shareName, shareDir string // TODO configurable at some point
|
shareName, shareDir := getShareDriveAndName()
|
||||||
switch runtime.GOOS {
|
|
||||||
case "windows":
|
|
||||||
shareName = "c/Users"
|
|
||||||
shareDir = "c:\\Users"
|
|
||||||
case "darwin":
|
|
||||||
shareName = "Users"
|
|
||||||
shareDir = "/Users"
|
|
||||||
case "linux":
|
|
||||||
shareName = "hosthome"
|
|
||||||
shareDir = "/home"
|
|
||||||
}
|
|
||||||
|
|
||||||
if shareDir != "" && !d.NoShare {
|
if shareDir != "" && !d.NoShare {
|
||||||
log.Debugf("setting up shareDir")
|
log.Debugf("setting up shareDir")
|
||||||
|
|
|
@ -24,3 +24,7 @@ func (d *Driver) IsVTXDisabled() bool {
|
||||||
func detectVBoxManageCmd() string {
|
func detectVBoxManageCmd() string {
|
||||||
return detectVBoxManageCmdInPath()
|
return detectVBoxManageCmdInPath()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func getShareDriveAndName() (string, string) {
|
||||||
|
return "Users", "/Users"
|
||||||
|
}
|
||||||
|
|
|
@ -0,0 +1,14 @@
|
||||||
|
package virtualbox
|
||||||
|
|
||||||
|
import (
|
||||||
|
"testing"
|
||||||
|
|
||||||
|
"github.com/stretchr/testify/assert"
|
||||||
|
)
|
||||||
|
func TestShareName(t *testing.T) {
|
||||||
|
name, dir := getShareDriveAndName()
|
||||||
|
|
||||||
|
assert.Equal(t, name, "Users")
|
||||||
|
assert.Equal(t, dir, "/Users")
|
||||||
|
|
||||||
|
}
|
|
@ -34,3 +34,7 @@ func (d *Driver) IsVTXDisabled() bool {
|
||||||
func detectVBoxManageCmd() string {
|
func detectVBoxManageCmd() string {
|
||||||
return detectVBoxManageCmdInPath()
|
return detectVBoxManageCmdInPath()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func getShareDriveAndName() (string, string) {
|
||||||
|
return "hosthome", "/home"
|
||||||
|
}
|
||||||
|
|
|
@ -0,0 +1,13 @@
|
||||||
|
package virtualbox
|
||||||
|
|
||||||
|
import (
|
||||||
|
"testing"
|
||||||
|
|
||||||
|
"github.com/stretchr/testify/assert"
|
||||||
|
)
|
||||||
|
func TestShareName(t *testing.T) {
|
||||||
|
name, dir := getShareDriveAndName()
|
||||||
|
|
||||||
|
assert.Equal(t, name, "hosthome")
|
||||||
|
assert.Equal(t, dir, "/home")
|
||||||
|
}
|
|
@ -89,3 +89,7 @@ func findVBoxInstallDirInRegistry() (string, error) {
|
||||||
|
|
||||||
return installDir, nil
|
return installDir, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func getShareDriveAndName() (string, string) {
|
||||||
|
return "c/Users", "c:\\Users"
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue