Skip to content
This repository was archived by the owner on Dec 17, 2021. It is now read-only.

Commit 6db75f6

Browse files
committed
commands/provision: Add
1 parent 77d5ac7 commit 6db75f6

File tree

2 files changed

+74
-0
lines changed

2 files changed

+74
-0
lines changed

commands/provision.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
package commands
2+
3+
import "github.com/docker/machine/libmachine"
4+
5+
func cmdProvision(c CommandLine, api libmachine.API) error {
6+
return runAction("provision", c, api)
7+
}

commands/provision_test.go

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
package commands
2+
3+
import (
4+
"testing"
5+
6+
"github.com/docker/machine/commands/commandstest"
7+
"github.com/docker/machine/drivers/fakedriver"
8+
"github.com/docker/machine/libmachine"
9+
"github.com/docker/machine/libmachine/auth"
10+
"github.com/docker/machine/libmachine/engine"
11+
"github.com/docker/machine/libmachine/host"
12+
"github.com/docker/machine/libmachine/libmachinetest"
13+
"github.com/docker/machine/libmachine/provision"
14+
"github.com/docker/machine/libmachine/swarm"
15+
"github.com/stretchr/testify/assert"
16+
)
17+
18+
func TestCmdProvision(t *testing.T) {
19+
testCases := []struct {
20+
commandLine CommandLine
21+
api libmachine.API
22+
expectedErr error
23+
}{
24+
{
25+
commandLine: &commandstest.FakeCommandLine{
26+
CliArgs: []string{"foo", "bar"},
27+
},
28+
api: &libmachinetest.FakeAPI{
29+
Hosts: []*host.Host{
30+
{
31+
Name: "foo",
32+
Driver: &fakedriver.Driver{},
33+
HostOptions: &host.Options{
34+
EngineOptions: &engine.Options{},
35+
AuthOptions: &auth.Options{},
36+
SwarmOptions: &swarm.Options{},
37+
},
38+
},
39+
{
40+
Name: "bar",
41+
Driver: &fakedriver.Driver{},
42+
HostOptions: &host.Options{
43+
EngineOptions: &engine.Options{},
44+
AuthOptions: &auth.Options{},
45+
SwarmOptions: &swarm.Options{},
46+
},
47+
},
48+
},
49+
},
50+
expectedErr: nil,
51+
},
52+
}
53+
54+
provision.SetDetector(&provision.FakeDetector{
55+
Provisioner: provision.NewFakeProvisioner(nil),
56+
})
57+
58+
// fakeprovisioner always returns "true" for compatible host, so we
59+
// just need to register it.
60+
provision.Register("fakeprovisioner", &provision.RegisteredProvisioner{
61+
New: provision.NewFakeProvisioner,
62+
})
63+
64+
for _, tc := range testCases {
65+
assert.Equal(t, tc.expectedErr, cmdProvision(tc.commandLine, tc.api))
66+
}
67+
}

0 commit comments

Comments
 (0)