@@ -61,65 +61,60 @@ func TestCreate(t *testing.T) {
6161 tests := []struct {
6262 doc string
6363 options createOptions
64+ name string
6465 expecterErr string
6566 }{
6667 {
6768 doc : "empty name" ,
6869 expecterErr : `context name cannot be empty` ,
6970 },
7071 {
71- doc : "reserved name" ,
72- options : createOptions {
73- name : "default" ,
74- },
72+ doc : "reserved name" ,
73+ name : "default" ,
7574 expecterErr : `"default" is a reserved context name` ,
7675 },
7776 {
78- doc : "whitespace-only name" ,
79- options : createOptions {
80- name : " " ,
81- },
77+ doc : "whitespace-only name" ,
78+ name : " " ,
8279 expecterErr : `context name " " is invalid` ,
8380 },
8481 {
85- doc : "existing context" ,
86- options : createOptions {
87- name : "existing-context" ,
88- },
82+ doc : "existing context" ,
83+ name : "existing-context" ,
8984 expecterErr : `context "existing-context" already exists` ,
9085 },
9186 {
92- doc : "invalid docker host" ,
87+ doc : "invalid docker host" ,
88+ name : "invalid-docker-host" ,
9389 options : createOptions {
94- name : "invalid-docker-host" ,
9590 endpoint : map [string ]string {
9691 "host" : "some///invalid/host" ,
9792 },
9893 },
9994 expecterErr : `unable to parse docker host` ,
10095 },
10196 {
102- doc : "ssh host with skip-tls-verify=false" ,
97+ doc : "ssh host with skip-tls-verify=false" ,
98+ name : "skip-tls-verify-false" ,
10399 options : createOptions {
104- name : "skip-tls-verify-false" ,
105100 endpoint : map [string ]string {
106101 "host" : "ssh://example.com,skip-tls-verify=false" ,
107102 },
108103 },
109104 },
110105 {
111- doc : "ssh host with skip-tls-verify=true" ,
106+ doc : "ssh host with skip-tls-verify=true" ,
107+ name : "skip-tls-verify-true" ,
112108 options : createOptions {
113- name : "skip-tls-verify-true" ,
114109 endpoint : map [string ]string {
115110 "host" : "ssh://example.com,skip-tls-verify=true" ,
116111 },
117112 },
118113 },
119114 {
120- doc : "ssh host with skip-tls-verify=INVALID" ,
115+ doc : "ssh host with skip-tls-verify=INVALID" ,
116+ name : "skip-tls-verify-invalid" ,
121117 options : createOptions {
122- name : "skip-tls-verify-invalid" ,
123118 endpoint : map [string ]string {
124119 "host" : "ssh://example.com" ,
125120 "skip-tls-verify" : "INVALID" ,
@@ -128,9 +123,9 @@ func TestCreate(t *testing.T) {
128123 expecterErr : `unable to create docker endpoint config: skip-tls-verify: parsing "INVALID": invalid syntax` ,
129124 },
130125 {
131- doc : "unknown option" ,
126+ doc : "unknown option" ,
127+ name : "unknown-option" ,
132128 options : createOptions {
133- name : "unknown-option" ,
134129 endpoint : map [string ]string {
135130 "UNKNOWN" : "value" ,
136131 },
@@ -140,7 +135,7 @@ func TestCreate(t *testing.T) {
140135 }
141136 for _ , tc := range tests {
142137 t .Run (tc .doc , func (t * testing.T ) {
143- err := runCreate (cli , & tc .options )
138+ err := runCreate (cli , tc . name , tc .options )
144139 if tc .expecterErr == "" {
145140 assert .NilError (t , err )
146141 } else {
@@ -159,8 +154,7 @@ func assertContextCreateLogging(t *testing.T, cli *test.FakeCli, n string) {
159154func TestCreateOrchestratorEmpty (t * testing.T ) {
160155 cli := makeFakeCli (t )
161156
162- err := runCreate (cli , & createOptions {
163- name : "test" ,
157+ err := runCreate (cli , "test" , createOptions {
164158 endpoint : map [string ]string {},
165159 })
166160 assert .NilError (t , err )
@@ -187,8 +181,7 @@ func TestCreateFromContext(t *testing.T) {
187181
188182 cli := makeFakeCli (t )
189183 cli .ResetOutputBuffers ()
190- assert .NilError (t , runCreate (cli , & createOptions {
191- name : "original" ,
184+ assert .NilError (t , runCreate (cli , "original" , createOptions {
192185 description : "original description" ,
193186 endpoint : map [string ]string {
194187 keyHost : "tcp://42.42.42.42:2375" ,
@@ -197,8 +190,7 @@ func TestCreateFromContext(t *testing.T) {
197190 assertContextCreateLogging (t , cli , "original" )
198191
199192 cli .ResetOutputBuffers ()
200- assert .NilError (t , runCreate (cli , & createOptions {
201- name : "dummy" ,
193+ assert .NilError (t , runCreate (cli , "dummy" , createOptions {
202194 description : "dummy description" ,
203195 endpoint : map [string ]string {
204196 keyHost : "tcp://24.24.24.24:2375" ,
@@ -211,9 +203,8 @@ func TestCreateFromContext(t *testing.T) {
211203 for _ , tc := range cases {
212204 t .Run (tc .name , func (t * testing.T ) {
213205 cli .ResetOutputBuffers ()
214- err := runCreate (cli , & createOptions {
206+ err := runCreate (cli , tc . name , createOptions {
215207 from : "original" ,
216- name : tc .name ,
217208 description : tc .description ,
218209 endpoint : tc .docker ,
219210 })
@@ -251,8 +242,7 @@ func TestCreateFromCurrent(t *testing.T) {
251242
252243 cli := makeFakeCli (t )
253244 cli .ResetOutputBuffers ()
254- assert .NilError (t , runCreate (cli , & createOptions {
255- name : "original" ,
245+ assert .NilError (t , runCreate (cli , "original" , createOptions {
256246 description : "original description" ,
257247 endpoint : map [string ]string {
258248 keyHost : "tcp://42.42.42.42:2375" ,
@@ -265,8 +255,7 @@ func TestCreateFromCurrent(t *testing.T) {
265255 for _ , tc := range cases {
266256 t .Run (tc .name , func (t * testing.T ) {
267257 cli .ResetOutputBuffers ()
268- err := runCreate (cli , & createOptions {
269- name : tc .name ,
258+ err := runCreate (cli , tc .name , createOptions {
270259 description : tc .description ,
271260 })
272261 assert .NilError (t , err )
0 commit comments