Skip to content

Commit 643b734

Browse files
committed
Remove duplicated FakeApi
Signed-off-by: David Gageot <david@gageot.net>
1 parent f00b0b8 commit 643b734

File tree

8 files changed

+116
-154
lines changed

8 files changed

+116
-154
lines changed

commands/commandstest/fake_lib_machine_api.go

Lines changed: 0 additions & 80 deletions
This file was deleted.

commands/env_test.go

Lines changed: 26 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ import (
1313
"github.com/docker/machine/libmachine/auth"
1414
"github.com/docker/machine/libmachine/host"
1515
"github.com/docker/machine/libmachine/libmachinetest"
16-
"github.com/docker/machine/libmachine/persist/persisttest"
1716
"github.com/docker/machine/libmachine/state"
1817
"github.com/stretchr/testify/assert"
1918
)
@@ -118,11 +117,9 @@ func TestShellCfgSet(t *testing.T) {
118117
},
119118
},
120119
api: &libmachinetest.FakeAPI{
121-
FakeStore: &persisttest.FakeStore{
122-
Hosts: []*host.Host{
123-
{
124-
Name: "quux",
125-
},
120+
Hosts: []*host.Host{
121+
{
122+
Name: "quux",
126123
},
127124
},
128125
},
@@ -156,11 +153,9 @@ func TestShellCfgSet(t *testing.T) {
156153
},
157154
},
158155
api: &libmachinetest.FakeAPI{
159-
FakeStore: &persisttest.FakeStore{
160-
Hosts: []*host.Host{
161-
{
162-
Name: "quux",
163-
},
156+
Hosts: []*host.Host{
157+
{
158+
Name: "quux",
164159
},
165160
},
166161
},
@@ -194,11 +189,9 @@ func TestShellCfgSet(t *testing.T) {
194189
},
195190
},
196191
api: &libmachinetest.FakeAPI{
197-
FakeStore: &persisttest.FakeStore{
198-
Hosts: []*host.Host{
199-
{
200-
Name: "quux",
201-
},
192+
Hosts: []*host.Host{
193+
{
194+
Name: "quux",
202195
},
203196
},
204197
},
@@ -232,11 +225,9 @@ func TestShellCfgSet(t *testing.T) {
232225
},
233226
},
234227
api: &libmachinetest.FakeAPI{
235-
FakeStore: &persisttest.FakeStore{
236-
Hosts: []*host.Host{
237-
{
238-
Name: "quux",
239-
},
228+
Hosts: []*host.Host{
229+
{
230+
Name: "quux",
240231
},
241232
},
242233
},
@@ -270,14 +261,12 @@ func TestShellCfgSet(t *testing.T) {
270261
},
271262
},
272263
api: &libmachinetest.FakeAPI{
273-
FakeStore: &persisttest.FakeStore{
274-
Hosts: []*host.Host{
275-
{
276-
Name: "quux",
277-
Driver: &fakedriver.Driver{
278-
MockState: state.Running,
279-
MockIP: "1.2.3.4",
280-
},
264+
Hosts: []*host.Host{
265+
{
266+
Name: "quux",
267+
Driver: &fakedriver.Driver{
268+
MockState: state.Running,
269+
MockIP: "1.2.3.4",
281270
},
282271
},
283272
},
@@ -316,14 +305,12 @@ func TestShellCfgSet(t *testing.T) {
316305
},
317306
},
318307
api: &libmachinetest.FakeAPI{
319-
FakeStore: &persisttest.FakeStore{
320-
Hosts: []*host.Host{
321-
{
322-
Name: "quux",
323-
Driver: &fakedriver.Driver{
324-
MockState: state.Running,
325-
MockIP: "1.2.3.4",
326-
},
308+
Hosts: []*host.Host{
309+
{
310+
Name: "quux",
311+
Driver: &fakedriver.Driver{
312+
MockState: state.Running,
313+
MockIP: "1.2.3.4",
327314
},
328315
},
329316
},
@@ -431,9 +418,7 @@ func TestShellCfgUnset(t *testing.T) {
431418
},
432419
},
433420
},
434-
api: &libmachinetest.FakeAPI{
435-
FakeStore: &persisttest.FakeStore{},
436-
},
421+
api: &libmachinetest.FakeAPI{},
437422
connChecker: &FakeConnChecker{
438423
DockerHost: "tcp://1.2.3.4:2376",
439424
AuthOptions: nil,
@@ -485,9 +470,7 @@ func TestShellCfgUnset(t *testing.T) {
485470
},
486471
},
487472
},
488-
api: &libmachinetest.FakeAPI{
489-
FakeStore: &persisttest.FakeStore{},
490-
},
473+
api: &libmachinetest.FakeAPI{},
491474
connChecker: &FakeConnChecker{
492475
DockerHost: "tcp://1.2.3.4:2376",
493476
AuthOptions: nil,

commands/ip_test.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,14 @@ import (
66
"github.com/docker/machine/commands/commandstest"
77
"github.com/docker/machine/drivers/fakedriver"
88
"github.com/docker/machine/libmachine/host"
9+
"github.com/docker/machine/libmachine/libmachinetest"
910
"github.com/docker/machine/libmachine/state"
1011
"github.com/stretchr/testify/assert"
1112
)
1213

1314
func TestCmdIPMissingMachineName(t *testing.T) {
1415
commandLine := &commandstest.FakeCommandLine{}
15-
api := &commandstest.FakeLibmachineAPI{}
16+
api := &libmachinetest.FakeAPI{}
1617

1718
err := cmdURL(commandLine, api)
1819

@@ -23,7 +24,7 @@ func TestCmdIP(t *testing.T) {
2324
commandLine := &commandstest.FakeCommandLine{
2425
CliArgs: []string{"machine"},
2526
}
26-
api := &commandstest.FakeLibmachineAPI{
27+
api := &libmachinetest.FakeAPI{
2728
Hosts: []*host.Host{
2829
{
2930
Name: "machine",

commands/kill_test.go

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,14 @@ import (
66
"github.com/docker/machine/commands/commandstest"
77
"github.com/docker/machine/drivers/fakedriver"
88
"github.com/docker/machine/libmachine/host"
9+
"github.com/docker/machine/libmachine/libmachinetest"
910
"github.com/docker/machine/libmachine/state"
1011
"github.com/stretchr/testify/assert"
1112
)
1213

1314
func TestCmdKillMissingMachineName(t *testing.T) {
1415
commandLine := &commandstest.FakeCommandLine{}
15-
api := &commandstest.FakeLibmachineAPI{}
16+
api := &libmachinetest.FakeAPI{}
1617

1718
err := cmdKill(commandLine, api)
1819

@@ -23,7 +24,7 @@ func TestCmdKill(t *testing.T) {
2324
commandLine := &commandstest.FakeCommandLine{
2425
CliArgs: []string{"machineToKill1", "machineToKill2"},
2526
}
26-
api := &commandstest.FakeLibmachineAPI{
27+
api := &libmachinetest.FakeAPI{
2728
Hosts: []*host.Host{
2829
{
2930
Name: "machineToKill1",
@@ -49,7 +50,7 @@ func TestCmdKill(t *testing.T) {
4950
err := cmdKill(commandLine, api)
5051
assert.NoError(t, err)
5152

52-
assert.Equal(t, state.Stopped, commandstest.State(api, "machineToKill1"))
53-
assert.Equal(t, state.Stopped, commandstest.State(api, "machineToKill2"))
54-
assert.Equal(t, state.Running, commandstest.State(api, "machine"))
53+
assert.Equal(t, state.Stopped, libmachinetest.State(api, "machineToKill1"))
54+
assert.Equal(t, state.Stopped, libmachinetest.State(api, "machineToKill2"))
55+
assert.Equal(t, state.Running, libmachinetest.State(api, "machine"))
5556
}

commands/rm_test.go

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,13 @@ import (
66
"github.com/docker/machine/commands/commandstest"
77
"github.com/docker/machine/drivers/fakedriver"
88
"github.com/docker/machine/libmachine/host"
9+
"github.com/docker/machine/libmachine/libmachinetest"
910
"github.com/stretchr/testify/assert"
1011
)
1112

1213
func TestCmdRmMissingMachineName(t *testing.T) {
1314
commandLine := &commandstest.FakeCommandLine{}
14-
api := &commandstest.FakeLibmachineAPI{}
15+
api := &libmachinetest.FakeAPI{}
1516

1617
err := cmdRm(commandLine, api)
1718

@@ -23,7 +24,7 @@ func TestCmdRm(t *testing.T) {
2324
commandLine := &commandstest.FakeCommandLine{
2425
CliArgs: []string{"machineToRemove1", "machineToRemove2"},
2526
}
26-
api := &commandstest.FakeLibmachineAPI{
27+
api := &libmachinetest.FakeAPI{
2728
Hosts: []*host.Host{
2829
{
2930
Name: "machineToRemove1",
@@ -43,7 +44,7 @@ func TestCmdRm(t *testing.T) {
4344
err := cmdRm(commandLine, api)
4445
assert.NoError(t, err)
4546

46-
assert.False(t, commandstest.Exists(api, "machineToRemove1"))
47-
assert.False(t, commandstest.Exists(api, "machineToRemove2"))
48-
assert.True(t, commandstest.Exists(api, "machine"))
47+
assert.False(t, libmachinetest.Exists(api, "machineToRemove1"))
48+
assert.False(t, libmachinetest.Exists(api, "machineToRemove2"))
49+
assert.True(t, libmachinetest.Exists(api, "machine"))
4950
}

commands/stop_test.go

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,14 @@ import (
66
"github.com/docker/machine/commands/commandstest"
77
"github.com/docker/machine/drivers/fakedriver"
88
"github.com/docker/machine/libmachine/host"
9+
"github.com/docker/machine/libmachine/libmachinetest"
910
"github.com/docker/machine/libmachine/state"
1011
"github.com/stretchr/testify/assert"
1112
)
1213

1314
func TestCmdStopMissingMachineName(t *testing.T) {
1415
commandLine := &commandstest.FakeCommandLine{}
15-
api := &commandstest.FakeLibmachineAPI{}
16+
api := &libmachinetest.FakeAPI{}
1617

1718
err := cmdStop(commandLine, api)
1819

@@ -23,7 +24,7 @@ func TestCmdStop(t *testing.T) {
2324
commandLine := &commandstest.FakeCommandLine{
2425
CliArgs: []string{"machineToStop1", "machineToStop2"},
2526
}
26-
api := &commandstest.FakeLibmachineAPI{
27+
api := &libmachinetest.FakeAPI{
2728
Hosts: []*host.Host{
2829
{
2930
Name: "machineToStop1",
@@ -49,7 +50,7 @@ func TestCmdStop(t *testing.T) {
4950
err := cmdStop(commandLine, api)
5051
assert.NoError(t, err)
5152

52-
assert.Equal(t, state.Stopped, commandstest.State(api, "machineToStop1"))
53-
assert.Equal(t, state.Stopped, commandstest.State(api, "machineToStop2"))
54-
assert.Equal(t, state.Running, commandstest.State(api, "machine"))
53+
assert.Equal(t, state.Stopped, libmachinetest.State(api, "machineToStop1"))
54+
assert.Equal(t, state.Stopped, libmachinetest.State(api, "machineToStop2"))
55+
assert.Equal(t, state.Running, libmachinetest.State(api, "machine"))
5556
}

commands/url_test.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,14 @@ import (
66
"github.com/docker/machine/commands/commandstest"
77
"github.com/docker/machine/drivers/fakedriver"
88
"github.com/docker/machine/libmachine/host"
9+
"github.com/docker/machine/libmachine/libmachinetest"
910
"github.com/docker/machine/libmachine/state"
1011
"github.com/stretchr/testify/assert"
1112
)
1213

1314
func TestCmdURLMissingMachineName(t *testing.T) {
1415
commandLine := &commandstest.FakeCommandLine{}
15-
api := &commandstest.FakeLibmachineAPI{}
16+
api := &libmachinetest.FakeAPI{}
1617

1718
err := cmdURL(commandLine, api)
1819

@@ -23,7 +24,7 @@ func TestCmdURLTooManyNames(t *testing.T) {
2324
commandLine := &commandstest.FakeCommandLine{
2425
CliArgs: []string{"machineToRemove1", "machineToRemove2"},
2526
}
26-
api := &commandstest.FakeLibmachineAPI{}
27+
api := &libmachinetest.FakeAPI{}
2728

2829
err := cmdURL(commandLine, api)
2930

@@ -34,7 +35,7 @@ func TestCmdURL(t *testing.T) {
3435
commandLine := &commandstest.FakeCommandLine{
3536
CliArgs: []string{"machine"},
3637
}
37-
api := &commandstest.FakeLibmachineAPI{
38+
api := &libmachinetest.FakeAPI{
3839
Hosts: []*host.Host{
3940
{
4041
Name: "machine",

0 commit comments

Comments
 (0)