Merge pull request #49 from marcosnils/container_services
Container services
This commit is contained in:
12
testutil/testutil.go
Normal file
12
testutil/testutil.go
Normal file
@@ -0,0 +1,12 @@
|
||||
package testutil
|
||||
|
||||
import "os"
|
||||
|
||||
var localhost = "localhost"
|
||||
|
||||
func GetLocalHost() string {
|
||||
if dockerHostVar := os.Getenv("DOCKER_HOST"); dockerHostVar != "" {
|
||||
return dockerHostVar
|
||||
}
|
||||
return localhost
|
||||
}
|
||||
26
testutil/testutil_test.go
Normal file
26
testutil/testutil_test.go
Normal file
@@ -0,0 +1,26 @@
|
||||
package testutil
|
||||
|
||||
import (
|
||||
"os"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestDockerHost(t *testing.T) {
|
||||
|
||||
os.Unsetenv("DOCKER_HOST")
|
||||
|
||||
host := GetLocalHost()
|
||||
|
||||
if host != localhost {
|
||||
t.Fatalf("Host should be localhost when DOCKER_HOST is not set. Current value [%s]", host)
|
||||
}
|
||||
|
||||
os.Setenv("DOCKER_HOST", "1.1.1.1")
|
||||
|
||||
host = GetLocalHost()
|
||||
|
||||
if host != "1.1.1.1" {
|
||||
t.Fatalf("Host should take DOCKER_HOST value when set. Current value is [%s] and DOCKER_HOST is [%s]", host, os.Getenv("DOCKER_HOST"))
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user