-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathdeploy_test.go
More file actions
140 lines (128 loc) · 2.46 KB
/
deploy_test.go
File metadata and controls
140 lines (128 loc) · 2.46 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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
package guvnor
import (
"testing"
"github.com/stretchr/testify/assert"
)
func Test_containerFullName(t *testing.T) {
serviceName := "foo"
deploymentID := 3
processName := "web"
count := 0
got := containerFullName(serviceName, deploymentID, processName, count)
assert.Equal(t, "foo-web-3-0", got)
}
func Test_mergeEnv(t *testing.T) {
tests := []struct {
name string
a, b map[string]string
want []string
}{
{
name: "merge",
a: map[string]string{
"aOnly": "foo",
"overrided": "foo",
},
b: map[string]string{
"bOnly": "bar",
"overrided": "bar",
},
want: []string{
"aOnly=foo",
"bOnly=bar",
"overrided=bar",
},
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
out := mergeEnv(tt.a, tt.b)
assert.ElementsMatch(t, tt.want, out)
})
}
}
func Test_mergeMounts(t *testing.T) {
tests := []struct {
name string
a, b []ServiceMountConfig
want []ServiceMountConfig
}{
{
name: "only in a",
a: []ServiceMountConfig{
{
Host: "/path/on/host/a",
Container: "/path/on/container",
},
},
b: []ServiceMountConfig{},
want: []ServiceMountConfig{
{
Host: "/path/on/host/a",
Container: "/path/on/container",
},
},
},
{
name: "only in b",
a: []ServiceMountConfig{},
b: []ServiceMountConfig{
{
Host: "/path/on/host/b",
Container: "/path/on/container",
},
},
want: []ServiceMountConfig{
{
Host: "/path/on/host/b",
Container: "/path/on/container",
},
},
},
{
name: "both",
a: []ServiceMountConfig{
{
Host: "/path/on/host/a",
Container: "/path/on/container/a",
},
},
b: []ServiceMountConfig{
{
Host: "/path/on/host/b",
Container: "/path/on/container/b",
},
},
want: []ServiceMountConfig{
{
Host: "/path/on/host/a",
Container: "/path/on/container/a",
},
{
Host: "/path/on/host/b",
Container: "/path/on/container/b",
},
},
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
out := mergeMounts(tt.a, tt.b)
assert.ElementsMatch(t, tt.want, out)
})
}
}
func Test_deployedContainerList_Pop(t *testing.T) {
list := deployedContainerList{
{
ID: "first",
},
}
container := list.pop()
assert.Equal(t, &deployedProcessContainer{
ID: "first",
}, container)
assert.Len(t, list, 0)
container = list.pop()
assert.Nil(t, container)
}