forked from adamlaska/machine
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhost_test.go
More file actions
57 lines (48 loc) · 1.09 KB
/
host_test.go
File metadata and controls
57 lines (48 loc) · 1.09 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
package host
import (
"testing"
"github.com/docker/machine/drivers/fakedriver"
_ "github.com/docker/machine/drivers/none"
"github.com/docker/machine/libmachine/provision"
"github.com/docker/machine/libmachine/state"
)
func TestValidateHostnameValid(t *testing.T) {
hosts := []string{
"zomg",
"test-ing",
"some.h0st",
}
for _, v := range hosts {
isValid := ValidateHostName(v)
if !isValid {
t.Fatalf("Thought a valid hostname was invalid: %s", v)
}
}
}
func TestValidateHostnameInvalid(t *testing.T) {
hosts := []string{
"zom_g",
"test$ing",
"some😄host",
}
for _, v := range hosts {
isValid := ValidateHostName(v)
if isValid {
t.Fatalf("Thought an invalid hostname was valid: %s", v)
}
}
}
func TestStart(t *testing.T) {
defer provision.SetDetector(&provision.StandardDetector{})
provision.SetDetector(&provision.FakeDetector{
Provisioner: provision.NewNetstatProvisioner(),
})
host := &Host{
Driver: &fakedriver.Driver{
MockState: state.Stopped,
},
}
if err := host.Start(); err != nil {
t.Fatalf("Expected no error but got one: %s", err)
}
}