This repository has been archived by the owner on Aug 28, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 78
/
docker_test.go
71 lines (62 loc) · 1.62 KB
/
docker_test.go
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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
package main
import (
"testing"
)
func Test_dockerPid_1(t *testing.T) {
pid, err := dockerpid("testcontainer")
if err != nil {
t.Errorf("Error from dockerpid: %v", err)
}
if pid != 666 {
t.Errorf("PID was %i expected 666", pid)
}
}
func Test_dockerSha_1(t *testing.T) {
sha, err := dockersha("testcontainer")
if err != nil {
t.Errorf("Error from dockersha: %v", err)
}
if sha != "666" {
t.Errorf("SHA was %s expected 666", sha)
}
}
func Test_dockerStart(t *testing.T) {
c := Configuration{ContainerName: "somecontainer", ImageName: "busybox", MountHome: true, MountHomeFrom: "/home/fred", MountHomeTo: "/home/fred", Entrypoint: "internal", DockerSocket: "dockersock", Cmd: []string{"foo"}, DockerOpt: []string{"bar"}}
pid, err := dockerstart(c)
if err != nil {
t.Errorf("Error from dockerstart: %v", err)
}
if pid != 666 {
t.Errorf("PID was %i expected 666", pid)
}
}
func Test_validatePortforwardString_1(t *testing.T) {
err := validatePortforwardString("1:2")
if err != nil {
t.Errorf("Error on 1:2")
}
}
func Test_validatePortforwardString_2(t *testing.T) {
err := validatePortforwardString("foobar")
if err == nil {
t.Errorf("No error on foobar")
}
}
func Test_validatePortforwardString_3(t *testing.T) {
err := validatePortforwardString("foo:bar")
if err == nil {
t.Errorf("No error on foo:bar")
}
}
func Test_validatePortforwardString_4(t *testing.T) {
err := validatePortforwardString("1:bar")
if err == nil {
t.Errorf("No error on 1:bar")
}
}
func Test_validatePortforwardString_5(t *testing.T) {
err := validatePortforwardString("foo:2")
if err == nil {
t.Errorf("No error on foo:2")
}
}