@@ -15,24 +15,35 @@ import (
15
15
func TestParseType (t * testing.T ) {
16
16
t .Parallel ()
17
17
18
- // test RC pod name
19
- appID := "earthy-underdog"
20
- rcPod := "earthy-underdog-v2-cmd-8yngj"
21
- psType , psName := parseType (rcPod , appID )
22
- if psType != "cmd" || psName != rcPod {
23
- t .Errorf ("type was not cmd (got %s) or psName was not %s (got %s)" , psType , rcPod , psName )
18
+ var input = map [string ]string {
19
+ // RC pod name
20
+ "earthy-underdog" : "earthy-underdog-v2-cmd-8yngj" ,
21
+ // Deployment pod name - they are longer due to hash
22
+ "nonfat-yearbook" : "nonfat-yearbook-cmd-2180299075-7na91" ,
23
+ // newer style of Deployment pod name
24
+ "foo-bar" : "foo-bar-cmd-57f6c4bb68-7na91" ,
25
+ // same as above but leaving out the app-name from the pod name
26
+ "earthy-underdog2" : "cmd-8yngj" ,
27
+ "nonfat-yearbook2" : "cmd-2180299075-7na91" ,
28
+ "foo-bar2" : "cmd-57f6c4bb68-7na91" ,
29
+ // same as above but with app names without hyphens
30
+ "earthy" : "earthy-v2-cmd-8yngj" ,
31
+ "nonfat" : "nonfat-cmd-2180299075-7na91" ,
32
+ "foo" : "foo-cmd-57f6c4bb68-7na91" ,
33
+ "earthy2" : "cmd-8yngj" ,
34
+ "nonfat2" : "cmd-2180299075-7na91" ,
35
+ "foo2" : "cmd-57f6c4bb68-7na91" ,
24
36
}
25
37
26
- // test Deployment pod name - they are longer due to hash
27
- appID = "nonfat-yearbook"
28
- deployPod := "nonfat-yearbook-cmd-2180299075-7na91"
29
- psType , psName = parseType (deployPod , appID )
30
- if psType != "cmd" || psName != deployPod {
31
- t .Errorf ("type was not cmd (got %s) or psName was not %s (got %s)" , psType , deployPod , psName )
38
+ for appID , podName := range input {
39
+ psType , psName := parseType (podName , appID )
40
+ if psType != "cmd" || psName != podName {
41
+ t .Errorf ("parseType(%#v, %#v): type was not cmd (got %s) or psName was not %s (got %s)" , podName , appID , psType , podName , psName )
42
+ }
32
43
}
33
44
34
45
// test type by itself
35
- psType , psName = parseType ("cmd" , "fake" )
46
+ psType , psName : = parseType ("cmd" , "fake" )
36
47
if psType != "cmd" || psName != "" {
37
48
t .Error ("type was not cmd" )
38
49
}
0 commit comments