@@ -14,43 +14,6 @@ import (
1414 "github.com/stretchr/testify/assert"
1515)
1616
17- func TestParseType (t * testing.T ) {
18- t .Parallel ()
19-
20- var input = map [string ]string {
21- // RC pod name
22- "earthy-underdog" : "earthy-underdog-v2-cmd-8yngj" ,
23- // Deployment pod name - they are longer due to hash
24- "nonfat-yearbook" : "nonfat-yearbook-cmd-2180299075-7na91" ,
25- // newer style of Deployment pod name
26- "foo-bar" : "foo-bar-cmd-57f6c4bb68-7na91" ,
27- // same as above but leaving out the app-name from the pod name
28- "earthy-underdog2" : "cmd-8yngj" ,
29- "nonfat-yearbook2" : "cmd-2180299075-7na91" ,
30- "foo-bar2" : "cmd-57f6c4bb68-7na91" ,
31- // same as above but with app names without hyphens
32- "earthy" : "earthy-v2-cmd-8yngj" ,
33- "nonfat" : "nonfat-cmd-2180299075-7na91" ,
34- "foo" : "foo-cmd-57f6c4bb68-7na91" ,
35- "earthy2" : "cmd-8yngj" ,
36- "nonfat2" : "cmd-2180299075-7na91" ,
37- "foo2" : "cmd-57f6c4bb68-7na91" ,
38- }
39-
40- for appID , podName := range input {
41- psType , psName := parseType (podName , appID )
42- if psType != "cmd" || psName != podName {
43- t .Errorf ("parseType(%#v, %#v): type was not cmd (got %s) or psName was not %s (got %s)" , podName , appID , psType , podName , psName )
44- }
45- }
46-
47- // test type by itself
48- psType , psName := parseType ("cmd" , "fake" )
49- if psType != "cmd" || psName != "" {
50- t .Error ("type was not cmd" )
51- }
52- }
53-
5417func TestPrintProcesses (t * testing.T ) {
5518 var b bytes.Buffer
5619
@@ -247,98 +210,30 @@ func TestPsRestart(t *testing.T) {
247210
248211 server .Mux .HandleFunc ("/v2/apps/foo/pods/restart/" , func (w http.ResponseWriter , r * http.Request ) {
249212 testutil .SetHeaders (w )
250- fmt .Fprintf (w , `[
251- {
252- "release": "v2",
253- "type": "web",
254- "name": "foo-web-4084101150-c871y",
255- "state": "up",
256- "started": "2016-02-13T00:47:52"
257- }
258- ]` )
213+ w .WriteHeader (http .StatusNoContent )
259214 })
260215
261216 b .Reset ()
262217 err = cmdr .PsRestart ("foo" , "" )
263218 assert .NoError (t , err )
264- assert .Equal (t , testutil .StripProgress (b .String ()), `Restarting processes... but first, coffee!
265- done in 0s
266- === foo Processes
267- --- web:
268- foo-web-4084101150-c871y up (v2)
269- ` , "output" )
270219
271220 server .Mux .HandleFunc ("/v2/apps/coolapp/pods/restart/" , func (w http.ResponseWriter , r * http.Request ) {
272221 testutil .SetHeaders (w )
273- fmt . Fprintf ( w , `[]` )
222+ w . WriteHeader ( http . StatusNoContent )
274223 })
275224
276225 b .Reset ()
277226
278227 err = cmdr .PsRestart ("coolapp" , "" )
279228 assert .NoError (t , err )
280- assert .Equal (t , testutil .StripProgress (b .String ()), `Restarting processes... but first, coffee!
281- Could not find any processes to restart
282- ` , "output" )
283229
284230 server .Mux .HandleFunc ("/v2/apps/testapp/pods/web/restart/" , func (w http.ResponseWriter , r * http.Request ) {
285231 testutil .SetHeaders (w )
286- fmt .Fprintf (w , `[
287- {
288- "release": "v2",
289- "type": "web",
290- "name": "testapp-web-4084101150-c871y",
291- "state": "up",
292- "started": "2016-02-13T00:47:52"
293- }
294- ]` )
232+ w .WriteHeader (http .StatusNoContent )
295233 })
296234
297235 b .Reset ()
298236
299237 err = cmdr .PsRestart ("testapp" , "web" )
300238 assert .NoError (t , err )
301- assert .Equal (t , testutil .StripProgress (b .String ()), `Restarting processes... but first, coffee!
302- done in 0s
303- === testapp Processes
304- --- web:
305- testapp-web-4084101150-c871y up (v2)
306- ` , "output" )
307-
308- server .Mux .HandleFunc ("/v2/apps/newapp/pods/web/newapp-web-4084101150-c871y/restart/" , func (w http.ResponseWriter , r * http.Request ) {
309- testutil .SetHeaders (w )
310- fmt .Fprintf (w , `[
311- {
312- "release": "v2",
313- "type": "web",
314- "name": "newapp-web-4084101150-c871y",
315- "state": "up",
316- "started": "2016-02-13T00:47:52"
317- }
318- ]` )
319- })
320-
321- b .Reset ()
322-
323- err = cmdr .PsRestart ("newapp" , "newapp-web-4084101150-c871y" )
324- assert .NoError (t , err )
325- assert .Equal (t , testutil .StripProgress (b .String ()), `Restarting processes... but first, coffee!
326- done in 0s
327- === newapp Processes
328- --- web:
329- newapp-web-4084101150-c871y up (v2)
330- ` , "output" )
331-
332- server .Mux .HandleFunc ("/v2/apps/newapp/pods/ghost/restart/" , func (w http.ResponseWriter , r * http.Request ) {
333- testutil .SetHeaders (w )
334- w .WriteHeader (http .StatusBadRequest )
335- fmt .Fprintf (w , `{
336- "detail": "Container type ghost does not exist in application"
337- }` )
338- })
339-
340- b .Reset ()
341-
342- err = cmdr .PsRestart ("newapp" , "ghost" )
343- assert .Equal (t , err .Error (), "Could not find process type ghost in app newapp" , "error" )
344239}
0 commit comments