@@ -154,39 +154,40 @@ func TestGenerate_OK(t *testing.T) {
154
154
155
155
func TestTemplateSupervisorFile_OK (t * testing.T ) {
156
156
ctx := context .TestContext (io .Discard )
157
-
157
+ groupName := "test-group"
158
158
workers := types.WorkerTasks {
159
159
{
160
160
Id : "test" ,
161
161
Command : "fake" ,
162
+ GroupName : groupName ,
162
163
User : "toto" ,
163
164
Directory : "/tmp/dir" ,
164
165
},
165
166
{
166
167
Id : "test2" ,
167
168
Command : "fake" ,
169
+ GroupName : groupName ,
168
170
User : "toto" ,
169
171
Directory : "/tmp/dir" ,
170
172
},
171
173
}
172
- groupName := "test-group"
173
174
174
175
expectedOutput := "[group:test-group]\n " +
175
- "programs=test, test2\n \n \n " +
176
- "[program:test]\n " +
176
+ "programs=test-group-test,test-group- test2\n \n \n " +
177
+ "[program:test-group-test ]\n " +
177
178
"directory = /tmp/dir\n " +
178
179
"autorestart = true\n " +
179
180
"autostart = true\n " +
180
181
"user = toto\n " +
181
182
"command = fake\n " +
182
- "environment = GTASK_GROUP_NAME=\" test-group\" ,GTASK_DIR=\" /tmp/dir\" ,GTASK_USER=\" toto\" ,GTASK_ID=\" test\" \n \n " +
183
- "[program:test2]\n " +
183
+ "environment = GTASK_GROUP_NAME=\" test-group\" ,GTASK_DIR=\" /tmp/dir\" ,GTASK_USER=\" toto\" ,GTASK_ID=\" test-group-test \" \n \n " +
184
+ "[program:test-group- test2]\n " +
184
185
"directory = /tmp/dir\n " +
185
186
"autorestart = true\n " +
186
187
"autostart = true\n " +
187
188
"user = toto\n " +
188
189
"command = fake\n " +
189
- "environment = GTASK_GROUP_NAME=\" test-group\" ,GTASK_DIR=\" /tmp/dir\" ,GTASK_USER=\" toto\" ,GTASK_ID=\" test2\" \n "
190
+ "environment = GTASK_GROUP_NAME=\" test-group\" ,GTASK_DIR=\" /tmp/dir\" ,GTASK_USER=\" toto\" ,GTASK_ID=\" test-group- test2\" \n "
190
191
191
192
ctx .Config .Workers = workers
192
193
@@ -199,22 +200,26 @@ func TestTemplateSupervisorFile_OK(t *testing.T) {
199
200
}
200
201
201
202
func TestGenerateProgramList (t * testing.T ) {
203
+ prefix := "pref"
202
204
workers := types.WorkerTasks {
203
205
{
204
206
Id : "test" ,
205
207
Command : "fake" ,
206
208
User : "toto" ,
207
209
Directory : "/tmp/dir" ,
210
+ GroupName : prefix ,
208
211
},
209
212
{
210
213
Id : "test2" ,
211
214
Command : "fake" ,
212
215
User : "toto" ,
213
216
Directory : "/tmp/dir" ,
217
+ GroupName : prefix ,
214
218
},
215
219
}
220
+
216
221
output := generateProgramList (workers )
217
- assert .Equal (t , output , " test,test2" )
222
+ assert .Equal (t , output , prefix + "- test," + prefix + "- test2" )
218
223
}
219
224
220
225
func TestDeleteFile_OK (t * testing.T ) {
@@ -276,16 +281,18 @@ func TestGenerate_NoErrorDeleteFile(t *testing.T) {
276
281
}
277
282
278
283
func TestGenerateEnvVars (t * testing.T ) {
284
+ groupName := "group"
285
+
279
286
worker := types.WorkerTask {
280
287
Id : "test2" ,
281
288
Command : "fake" ,
282
289
User : "toto" ,
290
+ GroupName : groupName ,
283
291
Directory : "/tmp/dir" ,
284
292
}
285
- groupName := "group"
286
- output := generateEnvVars (worker , groupName )
293
+ output := generateEnvVars (worker )
287
294
288
295
assert .Equal (t ,
289
- fmt .Sprintf ("GTASK_GROUP_NAME=\" %s\" ,GTASK_DIR=\" %s\" ,GTASK_USER=\" %s\" ,GTASK_ID=\" %s\" " , groupName , worker .Directory , worker .User , worker .Id ),
296
+ fmt .Sprintf ("GTASK_GROUP_NAME=\" %s\" ,GTASK_DIR=\" %s\" ,GTASK_USER=\" %s\" ,GTASK_ID=\" %s\" " , groupName , worker .Directory , worker .User , worker .PrefixedName () ),
290
297
output )
291
298
}
0 commit comments