@@ -29,13 +29,15 @@ func templ(tpl string) *template.Template {
29
29
func TestValidate (t * testing.T ) {
30
30
ctrl := gomock .NewController (t )
31
31
defer ctrl .Finish ()
32
+ managerStop := make (chan struct {})
33
+ workerStop := make (chan struct {})
32
34
33
35
managerFlavor := NewManagerFlavor (func (Spec ) (docker_client.APIClient , error ) {
34
36
return mock_client .NewMockAPIClient (ctrl ), nil
35
- }, templ (DefaultManagerInitScriptTemplate ))
37
+ }, templ (DefaultManagerInitScriptTemplate ), managerStop )
36
38
workerFlavor := NewWorkerFlavor (func (Spec ) (docker_client.APIClient , error ) {
37
39
return mock_client .NewMockAPIClient (ctrl ), nil
38
- }, templ (DefaultWorkerInitScriptTemplate ))
40
+ }, templ (DefaultWorkerInitScriptTemplate ), workerStop )
39
41
40
42
require .NoError (t , workerFlavor .Validate (
41
43
types .AnyString (`{"Docker" : {"Host":"unix:///var/run/docker.sock"}}` ),
@@ -75,17 +77,22 @@ func TestValidate(t *testing.T) {
75
77
group_types.AllocationMethod {LogicalIDs : []instance.LogicalID {"127.0.0.1" }})
76
78
require .Error (t , err )
77
79
require .Equal (t , "Invalid attachment Type 'keyboard', only ebs is supported" , err .Error ())
80
+
81
+ close (managerStop )
82
+ close (workerStop )
78
83
}
79
84
80
85
func TestWorker (t * testing.T ) {
81
86
ctrl := gomock .NewController (t )
82
87
defer ctrl .Finish ()
83
88
89
+ workerStop := make (chan struct {})
90
+
84
91
client := mock_client .NewMockAPIClient (ctrl )
85
92
86
93
flavorImpl := NewWorkerFlavor (func (Spec ) (docker_client.APIClient , error ) {
87
94
return client , nil
88
- }, templ (DefaultWorkerInitScriptTemplate ))
95
+ }, templ (DefaultWorkerInitScriptTemplate ), workerStop )
89
96
90
97
swarmInfo := swarm.Swarm {
91
98
ClusterInfo : swarm.ClusterInfo {ID : "ClusterUUID" },
@@ -137,6 +144,8 @@ func TestWorker(t *testing.T) {
137
144
instance.Description {Tags : map [string ]string {associationTag : associationID }})
138
145
require .NoError (t , err )
139
146
require .Equal (t , flavor .Healthy , health )
147
+
148
+ close (workerStop )
140
149
}
141
150
142
151
const nodeID = "my-node-id"
@@ -147,11 +156,13 @@ func TestManager(t *testing.T) {
147
156
ctrl := gomock .NewController (t )
148
157
defer ctrl .Finish ()
149
158
159
+ managerStop := make (chan struct {})
160
+
150
161
client := mock_client .NewMockAPIClient (ctrl )
151
162
152
163
flavorImpl := NewManagerFlavor (func (Spec ) (docker_client.APIClient , error ) {
153
164
return client , nil
154
- }, templ (DefaultManagerInitScriptTemplate ))
165
+ }, templ (DefaultManagerInitScriptTemplate ), managerStop )
155
166
156
167
swarmInfo := swarm.Swarm {
157
168
ClusterInfo : swarm.ClusterInfo {ID : "ClusterUUID" },
@@ -214,4 +225,6 @@ func TestManager(t *testing.T) {
214
225
instance.Description {Tags : map [string ]string {associationTag : associationID }})
215
226
require .NoError (t , err )
216
227
require .Equal (t , flavor .Healthy , health )
228
+
229
+ close (managerStop )
217
230
}
0 commit comments