@@ -12,53 +12,57 @@ func TestBestWorkspaceCreator(t *testing.T) {
1212 ctx := context .Background ()
1313 isOverridden := ! (runtime .GOOS == "darwin" && runtime .GOARCH == "amd64" )
1414
15+ type imageBehaviour struct {
16+ image string
17+ behaviour expect.Behaviour
18+ }
1519 for name , tc := range map [string ]struct {
16- behaviours map [ string ]expect. Behaviour
20+ behaviours [] imageBehaviour
1721 want workspaceCreatorType
1822 }{
1923 "nil steps" : {
2024 behaviours : nil ,
2125 want : workspaceCreatorVolume ,
2226 },
2327 "no steps" : {
24- behaviours : map [ string ]expect. Behaviour {},
28+ behaviours : [] imageBehaviour {},
2529 want : workspaceCreatorVolume ,
2630 },
2731 "root" : {
28- behaviours : map [ string ]expect. Behaviour {
29- "foo" : {Stdout : []byte ("0\n " )},
30- "bar" : {Stdout : []byte ("0\n " )},
32+ behaviours : [] imageBehaviour {
33+ { image : "foo" , behaviour : expect. Behaviour {Stdout : []byte ("0\n " )} },
34+ { image : "bar" , behaviour : expect. Behaviour {Stdout : []byte ("0\n " )} },
3135 },
3236 want : workspaceCreatorVolume ,
3337 },
3438 "same user" : {
35- behaviours : map [ string ]expect. Behaviour {
36- "foo" : {Stdout : []byte ("1000\n " )},
39+ behaviours : [] imageBehaviour {
40+ { image : "foo" , behaviour : expect. Behaviour {Stdout : []byte ("1000\n " )} },
3741 },
3842 want : workspaceCreatorBind ,
3943 },
4044 "different user" : {
41- behaviours : map [ string ]expect. Behaviour {
42- "foo" : {Stdout : []byte ("0\n " )},
43- "bar" : {Stdout : []byte ("1000\n " )},
45+ behaviours : [] imageBehaviour {
46+ { image : "foo" , behaviour : expect. Behaviour {Stdout : []byte ("0\n " )} },
47+ { image : "bar" , behaviour : expect. Behaviour {Stdout : []byte ("1000\n " )} },
4448 },
4549 want : workspaceCreatorBind ,
4650 },
4751 "invalid id output: string" : {
48- behaviours : map [ string ]expect. Behaviour {
49- "foo" : {Stdout : []byte ("xxx\n " )},
52+ behaviours : [] imageBehaviour {
53+ { image : "foo" , behaviour : expect. Behaviour {Stdout : []byte ("xxx\n " )} },
5054 },
5155 want : workspaceCreatorBind ,
5256 },
5357 "invalid id output: empty" : {
54- behaviours : map [ string ]expect. Behaviour {
55- "foo" : {Stdout : []byte ("" )},
58+ behaviours : [] imageBehaviour {
59+ { image : "foo" , behaviour : expect. Behaviour {Stdout : []byte ("" )} },
5660 },
5761 want : workspaceCreatorBind ,
5862 },
5963 "error invoking id" : {
60- behaviours : map [ string ]expect. Behaviour {
61- "foo" : {ExitCode : 1 },
64+ behaviours : [] imageBehaviour {
65+ { image : "foo" , behaviour : expect. Behaviour {ExitCode : 1 } },
6266 },
6367 want : workspaceCreatorBind ,
6468 },
@@ -71,13 +75,13 @@ func TestBestWorkspaceCreator(t *testing.T) {
7175 if tc .behaviours != nil {
7276 commands = []* expect.Expectation {}
7377 steps = []Step {}
74- for image , behaviour := range tc .behaviours {
78+ for _ , imageBehaviour := range tc .behaviours {
7579 commands = append (commands , expect .NewGlob (
76- behaviour ,
80+ imageBehaviour . behaviour ,
7781 "docker" , "run" , "--rm" , "--entrypoint" , "/bin/sh" ,
78- image , "-c" , "id -u" ,
82+ imageBehaviour . image , "-c" , "id -u" ,
7983 ))
80- steps = append (steps , Step {image : image })
84+ steps = append (steps , Step {image : imageBehaviour . image })
8185 }
8286 }
8387
0 commit comments