forked from influxdata/telegraf
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcontainer_test.go
71 lines (56 loc) · 1.3 KB
/
container_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 testutil
import (
"testing"
"github.com/stretchr/testify/require"
)
func TestEmptyContainerIntegration(t *testing.T) {
if testing.Short() {
t.Skip("Skipping integration test in short mode")
}
container := Container{
Image: "docksal/empty",
}
err := container.Start()
require.NoError(t, err)
container.Terminate()
}
func TestMappedPortLookupIntegration(t *testing.T) {
if testing.Short() {
t.Skip("Skipping integration test in short mode")
}
cases := []struct {
name string
port string
expected string
}{
{"random", "80", "80"},
{"only 80", "80:80", "80"},
{"only 80", "80:80/tcp", "80"},
{"only 8080", "8080:80", "8080"},
{"only 8080", "8080:80/tcp", "8080"},
}
for _, tc := range cases {
container := Container{
Image: "nginx:stable-alpine",
ExposedPorts: []string{tc.port},
}
err := container.Start()
require.NoError(t, err)
if tc.name == "random" {
require.NotEqual(t, tc.expected, container.Ports["80"])
} else {
require.Equal(t, tc.expected, container.Ports["80"])
}
container.Terminate()
}
}
func TestBadImageNameIntegration(t *testing.T) {
if testing.Short() {
t.Skip("Skipping integration test in short mode")
}
container := Container{
Image: "fAk3-n4mE",
}
err := container.Start()
require.Error(t, err)
}