@@ -13,6 +13,7 @@ import (
1313 "github.com/docker/machine/libmachine/check"
1414 "github.com/docker/machine/libmachine/host"
1515 "github.com/docker/machine/libmachine/libmachinetest"
16+ "github.com/docker/machine/libmachine/mcndockerclient"
1617 "github.com/docker/machine/libmachine/state"
1718 "github.com/stretchr/testify/assert"
1819)
@@ -96,6 +97,7 @@ func revertUsageHinter(uhg UsageHintGenerator) {
9697}
9798
9899func TestShellCfgSet (t * testing.T ) {
100+ mcndockerclient .CurrentDockerVersioner = & mcndockerclient.FakeDockerVersioner {APIVersion : "1.21" }
99101 const (
100102 usageHint = "This is a usage hint"
101103 )
@@ -152,15 +154,16 @@ func TestShellCfgSet(t *testing.T) {
152154 Err : nil ,
153155 },
154156 expectedShellCfg : & ShellConfig {
155- Prefix : "export " ,
156- Delimiter : "=\" " ,
157- Suffix : "\" \n " ,
158- DockerCertPath : filepath .Join (mcndirs .GetMachineDir (), "quux" ),
159- DockerHost : "tcp://1.2.3.4:2376" ,
160- DockerTLSVerify : "1" ,
161- UsageHint : usageHint ,
162- MachineName : "quux" ,
163- ComposePathsVar : isRuntimeWindows ,
157+ Prefix : "export " ,
158+ Delimiter : "=\" " ,
159+ Suffix : "\" \n " ,
160+ DockerCertPath : filepath .Join (mcndirs .GetMachineDir (), "quux" ),
161+ DockerHost : "tcp://1.2.3.4:2376" ,
162+ DockerTLSVerify : "1" ,
163+ DockerAPIVersion : "1.21" ,
164+ UsageHint : usageHint ,
165+ MachineName : "quux" ,
166+ ComposePathsVar : isRuntimeWindows ,
164167 },
165168 expectedErr : nil ,
166169 },
@@ -189,15 +192,16 @@ func TestShellCfgSet(t *testing.T) {
189192 Err : nil ,
190193 },
191194 expectedShellCfg : & ShellConfig {
192- Prefix : "export " ,
193- Delimiter : "=\" " ,
194- Suffix : "\" \n " ,
195- DockerCertPath : filepath .Join (mcndirs .GetMachineDir (), defaultMachineName ),
196- DockerHost : "tcp://1.2.3.4:2376" ,
197- DockerTLSVerify : "1" ,
198- UsageHint : usageHint ,
199- MachineName : defaultMachineName ,
200- ComposePathsVar : isRuntimeWindows ,
195+ Prefix : "export " ,
196+ Delimiter : "=\" " ,
197+ Suffix : "\" \n " ,
198+ DockerCertPath : filepath .Join (mcndirs .GetMachineDir (), defaultMachineName ),
199+ DockerHost : "tcp://1.2.3.4:2376" ,
200+ DockerTLSVerify : "1" ,
201+ DockerAPIVersion : "1.21" ,
202+ UsageHint : usageHint ,
203+ MachineName : defaultMachineName ,
204+ ComposePathsVar : isRuntimeWindows ,
201205 },
202206 expectedErr : nil ,
203207 },
@@ -226,15 +230,16 @@ func TestShellCfgSet(t *testing.T) {
226230 Err : nil ,
227231 },
228232 expectedShellCfg : & ShellConfig {
229- Prefix : "set -gx " ,
230- Suffix : "\" ;\n " ,
231- Delimiter : " \" " ,
232- DockerCertPath : filepath .Join (mcndirs .GetMachineDir (), "quux" ),
233- DockerHost : "tcp://1.2.3.4:2376" ,
234- DockerTLSVerify : "1" ,
235- UsageHint : usageHint ,
236- MachineName : "quux" ,
237- ComposePathsVar : isRuntimeWindows ,
233+ Prefix : "set -gx " ,
234+ Suffix : "\" ;\n " ,
235+ Delimiter : " \" " ,
236+ DockerCertPath : filepath .Join (mcndirs .GetMachineDir (), "quux" ),
237+ DockerHost : "tcp://1.2.3.4:2376" ,
238+ DockerTLSVerify : "1" ,
239+ DockerAPIVersion : "1.21" ,
240+ UsageHint : usageHint ,
241+ MachineName : "quux" ,
242+ ComposePathsVar : isRuntimeWindows ,
238243 },
239244 expectedErr : nil ,
240245 },
@@ -263,15 +268,16 @@ func TestShellCfgSet(t *testing.T) {
263268 Err : nil ,
264269 },
265270 expectedShellCfg : & ShellConfig {
266- Prefix : "$Env:" ,
267- Suffix : "\" \n " ,
268- Delimiter : " = \" " ,
269- DockerCertPath : filepath .Join (mcndirs .GetMachineDir (), "quux" ),
270- DockerHost : "tcp://1.2.3.4:2376" ,
271- DockerTLSVerify : "1" ,
272- UsageHint : usageHint ,
273- MachineName : "quux" ,
274- ComposePathsVar : isRuntimeWindows ,
271+ Prefix : "$Env:" ,
272+ Suffix : "\" \n " ,
273+ Delimiter : " = \" " ,
274+ DockerCertPath : filepath .Join (mcndirs .GetMachineDir (), "quux" ),
275+ DockerHost : "tcp://1.2.3.4:2376" ,
276+ DockerTLSVerify : "1" ,
277+ DockerAPIVersion : "1.21" ,
278+ UsageHint : usageHint ,
279+ MachineName : "quux" ,
280+ ComposePathsVar : isRuntimeWindows ,
275281 },
276282 expectedErr : nil ,
277283 },
@@ -300,15 +306,16 @@ func TestShellCfgSet(t *testing.T) {
300306 Err : nil ,
301307 },
302308 expectedShellCfg : & ShellConfig {
303- Prefix : "(setenv \" " ,
304- Suffix : "\" )\n " ,
305- Delimiter : "\" \" " ,
306- DockerCertPath : filepath .Join (mcndirs .GetMachineDir (), "quux" ),
307- DockerHost : "tcp://1.2.3.4:2376" ,
308- DockerTLSVerify : "1" ,
309- UsageHint : usageHint ,
310- MachineName : "quux" ,
311- ComposePathsVar : isRuntimeWindows ,
309+ Prefix : "(setenv \" " ,
310+ Suffix : "\" )\n " ,
311+ Delimiter : "\" \" " ,
312+ DockerCertPath : filepath .Join (mcndirs .GetMachineDir (), "quux" ),
313+ DockerHost : "tcp://1.2.3.4:2376" ,
314+ DockerTLSVerify : "1" ,
315+ DockerAPIVersion : "1.21" ,
316+ UsageHint : usageHint ,
317+ MachineName : "quux" ,
318+ ComposePathsVar : isRuntimeWindows ,
312319 },
313320 expectedErr : nil ,
314321 },
@@ -337,15 +344,16 @@ func TestShellCfgSet(t *testing.T) {
337344 Err : nil ,
338345 },
339346 expectedShellCfg : & ShellConfig {
340- Prefix : "SET " ,
341- Suffix : "\n " ,
342- Delimiter : "=" ,
343- DockerCertPath : filepath .Join (mcndirs .GetMachineDir (), "quux" ),
344- DockerHost : "tcp://1.2.3.4:2376" ,
345- DockerTLSVerify : "1" ,
346- UsageHint : usageHint ,
347- MachineName : "quux" ,
348- ComposePathsVar : isRuntimeWindows ,
347+ Prefix : "SET " ,
348+ Suffix : "\n " ,
349+ Delimiter : "=" ,
350+ DockerCertPath : filepath .Join (mcndirs .GetMachineDir (), "quux" ),
351+ DockerHost : "tcp://1.2.3.4:2376" ,
352+ DockerTLSVerify : "1" ,
353+ DockerAPIVersion : "1.21" ,
354+ UsageHint : usageHint ,
355+ MachineName : "quux" ,
356+ ComposePathsVar : isRuntimeWindows ,
349357 },
350358 expectedErr : nil ,
351359 },
@@ -378,17 +386,18 @@ func TestShellCfgSet(t *testing.T) {
378386 Err : nil ,
379387 },
380388 expectedShellCfg : & ShellConfig {
381- Prefix : "export " ,
382- Delimiter : "=\" " ,
383- Suffix : "\" \n " ,
384- DockerCertPath : filepath .Join (mcndirs .GetMachineDir (), "quux" ),
385- DockerHost : "tcp://1.2.3.4:2376" ,
386- DockerTLSVerify : "1" ,
387- UsageHint : usageHint ,
388- NoProxyVar : "NO_PROXY" ,
389- NoProxyValue : "1.2.3.4" , // From FakeDriver
390- MachineName : "quux" ,
391- ComposePathsVar : isRuntimeWindows ,
389+ Prefix : "export " ,
390+ Delimiter : "=\" " ,
391+ Suffix : "\" \n " ,
392+ DockerCertPath : filepath .Join (mcndirs .GetMachineDir (), "quux" ),
393+ DockerHost : "tcp://1.2.3.4:2376" ,
394+ DockerTLSVerify : "1" ,
395+ DockerAPIVersion : "1.21" ,
396+ UsageHint : usageHint ,
397+ NoProxyVar : "NO_PROXY" ,
398+ NoProxyValue : "1.2.3.4" , // From FakeDriver
399+ MachineName : "quux" ,
400+ ComposePathsVar : isRuntimeWindows ,
392401 },
393402 noProxyVar : "NO_PROXY" ,
394403 noProxyValue : "" ,
@@ -423,17 +432,18 @@ func TestShellCfgSet(t *testing.T) {
423432 Err : nil ,
424433 },
425434 expectedShellCfg : & ShellConfig {
426- Prefix : "export " ,
427- Delimiter : "=\" " ,
428- Suffix : "\" \n " ,
429- DockerCertPath : filepath .Join (mcndirs .GetMachineDir (), "quux" ),
430- DockerHost : "tcp://1.2.3.4:2376" ,
431- DockerTLSVerify : "1" ,
432- UsageHint : usageHint ,
433- NoProxyVar : "no_proxy" ,
434- NoProxyValue : "192.168.59.1,1.2.3.4" , // From FakeDriver
435- MachineName : "quux" ,
436- ComposePathsVar : isRuntimeWindows ,
435+ Prefix : "export " ,
436+ Delimiter : "=\" " ,
437+ Suffix : "\" \n " ,
438+ DockerCertPath : filepath .Join (mcndirs .GetMachineDir (), "quux" ),
439+ DockerHost : "tcp://1.2.3.4:2376" ,
440+ DockerTLSVerify : "1" ,
441+ DockerAPIVersion : "1.21" ,
442+ UsageHint : usageHint ,
443+ NoProxyVar : "no_proxy" ,
444+ NoProxyValue : "192.168.59.1,1.2.3.4" , // From FakeDriver
445+ MachineName : "quux" ,
446+ ComposePathsVar : isRuntimeWindows ,
437447 },
438448 noProxyVar : "no_proxy" ,
439449 noProxyValue : "192.168.59.1" ,
@@ -458,6 +468,7 @@ func TestShellCfgSet(t *testing.T) {
458468}
459469
460470func TestShellCfgSetWindowsRuntime (t * testing.T ) {
471+ mcndockerclient .CurrentDockerVersioner = & mcndockerclient.FakeDockerVersioner {APIVersion : "1.21" }
461472 const (
462473 usageHint = "This is a usage hint"
463474 )
@@ -502,15 +513,16 @@ func TestShellCfgSetWindowsRuntime(t *testing.T) {
502513 Err : nil ,
503514 },
504515 expectedShellCfg : & ShellConfig {
505- Prefix : "$Env:" ,
506- Suffix : "\" \n " ,
507- Delimiter : " = \" " ,
508- DockerCertPath : filepath .Join (mcndirs .GetMachineDir (), "quux" ),
509- DockerHost : "tcp://1.2.3.4:2376" ,
510- DockerTLSVerify : "1" ,
511- UsageHint : usageHint ,
512- MachineName : "quux" ,
513- ComposePathsVar : true ,
516+ Prefix : "$Env:" ,
517+ Suffix : "\" \n " ,
518+ Delimiter : " = \" " ,
519+ DockerCertPath : filepath .Join (mcndirs .GetMachineDir (), "quux" ),
520+ DockerHost : "tcp://1.2.3.4:2376" ,
521+ DockerTLSVerify : "1" ,
522+ DockerAPIVersion : "1.21" ,
523+ UsageHint : usageHint ,
524+ MachineName : "quux" ,
525+ ComposePathsVar : true ,
514526 },
515527 expectedErr : nil ,
516528 },
@@ -537,6 +549,7 @@ func TestShellCfgSetWindowsRuntime(t *testing.T) {
537549}
538550
539551func TestShellCfgUnset (t * testing.T ) {
552+ mcndockerclient .CurrentDockerVersioner = & mcndockerclient.FakeDockerVersioner {APIVersion : "1.21" }
540553 const (
541554 usageHint = "This is the unset usage hint"
542555 )
0 commit comments