mirror of
https://github.com/woodpecker-ci/woodpecker.git
synced 2024-11-26 20:01:02 +00:00
32 lines
503 B
Go
32 lines
503 B
Go
package docker
|
|
|
|
import (
|
|
"os"
|
|
"testing"
|
|
)
|
|
|
|
func TestHostFromEnv(t *testing.T) {
|
|
os.Setenv("DOCKER_HOST", "tcp://1.1.1.1:2375")
|
|
defer os.Setenv("DOCKER_HOST", "")
|
|
|
|
client := New()
|
|
|
|
if client.proto != "tcp" {
|
|
t.Fail()
|
|
}
|
|
|
|
if client.addr != "1.1.1.1:2375" {
|
|
t.Fail()
|
|
}
|
|
}
|
|
|
|
func TestInvalidHostFromEnv(t *testing.T) {
|
|
os.Setenv("DOCKER_HOST", "tcp:1.1.1.1:2375") // missing tcp:// prefix
|
|
defer os.Setenv("DOCKER_HOST", "")
|
|
|
|
client := New()
|
|
|
|
if client.addr == "1.1.1.1:2375" {
|
|
t.Fail()
|
|
}
|
|
}
|