@@ -10,6 +10,7 @@ import (
1010
1111 "github.com/docker/machine/drivers/fakedriver"
1212 "github.com/docker/machine/libmachine/host"
13+ "github.com/docker/machine/libmachine/mcndockerclient"
1314 "github.com/docker/machine/libmachine/state"
1415 "github.com/docker/machine/libmachine/swarm"
1516 "github.com/stretchr/testify/assert"
@@ -296,6 +297,9 @@ func TestFilterHostsDifferentFlagsProduceAND(t *testing.T) {
296297}
297298
298299func TestGetHostListItems (t * testing.T ) {
300+ mcndockerclient .CurrentDockerVersioner = & mcndockerclient.FakeDockerVersioner {Version : "1.9" }
301+ defer mcndockerclient .CleanupDockerVersioner ()
302+
299303 // TODO: Ideally this would mockable via interface instead.
300304 os .Setenv ("DOCKER_HOST" , "tcp://active.host.com:2376" )
301305
@@ -331,14 +335,15 @@ func TestGetHostListItems(t *testing.T) {
331335 }
332336
333337 expected := []struct {
334- name string
335- state state.State
336- active bool
337- error string
338+ name string
339+ state state.State
340+ active bool
341+ version string
342+ error string
338343 }{
339- {"bar10" , state .Error , false , "Unable to get ip" },
340- {"bar100" , state .Stopped , false , "" },
341- {"foo" , state .Running , true , "" },
344+ {"bar10" , state .Error , false , "Unknown" , " Unable to get ip" },
345+ {"bar100" , state .Stopped , false , "Unknown" , " " },
346+ {"foo" , state .Running , true , "v1.9" , " " },
342347 }
343348
344349 items := getHostListItems (hosts , map [string ]error {})
@@ -347,6 +352,7 @@ func TestGetHostListItems(t *testing.T) {
347352 assert .Equal (t , expected [i ].name , items [i ].Name )
348353 assert .Equal (t , expected [i ].state , items [i ].State )
349354 assert .Equal (t , expected [i ].active , items [i ].Active )
355+ assert .Equal (t , expected [i ].version , items [i ].DockerVersion )
350356 assert .Equal (t , expected [i ].error , items [i ].Error )
351357 }
352358
@@ -355,6 +361,9 @@ func TestGetHostListItems(t *testing.T) {
355361
356362// issue #1908
357363func TestGetHostListItemsEnvDockerHostUnset (t * testing.T ) {
364+ mcndockerclient .CurrentDockerVersioner = & mcndockerclient.FakeDockerVersioner {Version : "1.9" }
365+ defer mcndockerclient .CleanupDockerVersioner ()
366+
358367 orgDockerHost := os .Getenv ("DOCKER_HOST" )
359368 defer func () {
360369 // revert DOCKER_HOST
@@ -408,12 +417,13 @@ func TestGetHostListItemsEnvDockerHostUnset(t *testing.T) {
408417 }
409418
410419 expected := map [string ]struct {
411- state state.State
412- active bool
420+ state state.State
421+ active bool
422+ version string
413423 }{
414- "foo" : {state .Running , false },
415- "bar" : {state .Stopped , false },
416- "baz" : {state .Saved , false },
424+ "foo" : {state .Running , false , "v1.9" },
425+ "bar" : {state .Stopped , false , "Unknown" },
426+ "baz" : {state .Saved , false , "Unknown" },
417427 }
418428
419429 items := getHostListItems (hosts , map [string ]error {})
@@ -423,6 +433,7 @@ func TestGetHostListItemsEnvDockerHostUnset(t *testing.T) {
423433
424434 assert .Equal (t , expected .state , item .State )
425435 assert .Equal (t , expected .active , item .Active )
436+ assert .Equal (t , expected .version , item .DockerVersion )
426437 }
427438}
428439
@@ -463,7 +474,7 @@ func TestGetHostStateTimeout(t *testing.T) {
463474 },
464475 }
465476
466- stateTimeoutDuration = 1 * time .Second
477+ stateTimeoutDuration = 1 * time .Millisecond
467478 hostItems := getHostListItems (hosts , map [string ]error {})
468479 hostItem := hostItems [0 ]
469480
@@ -496,6 +507,9 @@ func TestGetHostStateError(t *testing.T) {
496507}
497508
498509func TestGetSomeHostInEror (t * testing.T ) {
510+ mcndockerclient .CurrentDockerVersioner = & mcndockerclient.FakeDockerVersioner {Version : "1.9" }
511+ defer mcndockerclient .CleanupDockerVersioner ()
512+
499513 hosts := []* host.Host {
500514 {
501515 Name : "foo" ,
0 commit comments