forked from scriptsrc/ec2metaproxy
-
Notifications
You must be signed in to change notification settings - Fork 0
/
container_test.go
52 lines (44 loc) · 1.48 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
package ec2metaproxy
import (
"testing"
"github.com/fsouza/go-dockerclient"
"github.com/stretchr/testify/assert"
)
func TestGenerateSessionName(t *testing.T) {
assert := assert.New(t)
assert.Equal("ner_path_tag-ender_colden-69efa4", generateSessionName(&docker.Container{
ID: "69efa4b5bea1c69ce4c30c0b81925f8e4299c5661e1a880feb6e0be5a9178f98",
Name: "/tender_colden",
Config: &docker.Config{
Image: "docker-registry.host.com/container/path:tag",
},
}))
assert.Equal("ner_path_tag-ender_colden-69efa4", generateSessionName(&docker.Container{
ID: "69efa4b5bea1c69ce4c30c0b81925f8e4299c5661e1a880feb6e0be5a9178f98",
Name: "/ender_colden",
Config: &docker.Config{
Image: "docker-registry.host.com/container/path:tag",
},
}))
assert.Equal("iner_path_tag-nder_colden-69efa4", generateSessionName(&docker.Container{
ID: "69efa4b5bea1c69ce4c30c0b81925f8e4299c5661e1a880feb6e0be5a9178f98",
Name: "/nder_colden",
Config: &docker.Config{
Image: "docker-registry.host.com/container/path:tag",
},
}))
assert.Equal("image-cont-69efa4", generateSessionName(&docker.Container{
ID: "69efa4b5bea1c69ce4c30c0b81925f8e4299c5661e1a880feb6e0be5a9178f98",
Name: "/cont",
Config: &docker.Config{
Image: "image",
},
}))
assert.Equal("image-container_name-69efa4", generateSessionName(&docker.Container{
ID: "69efa4b5bea1c69ce4c30c0b81925f8e4299c5661e1a880feb6e0be5a9178f98",
Name: "/container_name",
Config: &docker.Config{
Image: "image",
},
}))
}