Merge pull request #1870 from kechol/add-argument-assertion
Add argument assertions to inspect/status/url commands
This commit is contained in:
@@ -23,6 +23,11 @@ var funcMap = template.FuncMap{
|
||||
}
|
||||
|
||||
func cmdInspect(c *cli.Context) {
|
||||
if len(c.Args()) == 0 {
|
||||
cli.ShowCommandHelp(c, "inspect")
|
||||
log.Fatal("You must specify a machine name")
|
||||
}
|
||||
|
||||
tmplString := c.String("format")
|
||||
if tmplString != "" {
|
||||
var tmpl *template.Template
|
||||
|
||||
+4
-2
@@ -1,12 +1,14 @@
|
||||
package commands
|
||||
|
||||
import (
|
||||
"github.com/docker/machine/libmachine/log"
|
||||
|
||||
"github.com/codegangsta/cli"
|
||||
"github.com/docker/machine/libmachine/log"
|
||||
)
|
||||
|
||||
func cmdStatus(c *cli.Context) {
|
||||
if len(c.Args()) != 1 {
|
||||
log.Fatal(ErrExpectedOneMachine)
|
||||
}
|
||||
host := getFirstArgHost(c)
|
||||
currentState, err := host.Driver.GetState()
|
||||
if err != nil {
|
||||
|
||||
+4
-2
@@ -3,12 +3,14 @@ package commands
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/docker/machine/libmachine/log"
|
||||
|
||||
"github.com/codegangsta/cli"
|
||||
"github.com/docker/machine/libmachine/log"
|
||||
)
|
||||
|
||||
func cmdUrl(c *cli.Context) {
|
||||
if len(c.Args()) != 1 {
|
||||
log.Fatal(ErrExpectedOneMachine)
|
||||
}
|
||||
url, err := getFirstArgHost(c).GetURL()
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
#!/usr/bin/env bats
|
||||
|
||||
load ${BASE_TEST_DIR}/helpers.bash
|
||||
|
||||
@test "inspect: show error in case of no args" {
|
||||
run machine inspect
|
||||
[ "$status" -eq 1 ]
|
||||
[[ ${output} == *"must specify a machine name"* ]]
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
#!/usr/bin/env bats
|
||||
|
||||
load ${BASE_TEST_DIR}/helpers.bash
|
||||
|
||||
@test "status: show error in case of no args" {
|
||||
run machine inspect
|
||||
[ "$status" -eq 1 ]
|
||||
[[ ${output} == *"must specify a machine name"* ]]
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
#!/usr/bin/env bats
|
||||
|
||||
load ${BASE_TEST_DIR}/helpers.bash
|
||||
|
||||
@test "url: show error in case of no args" {
|
||||
run machine inspect
|
||||
[ "$status" -eq 1 ]
|
||||
[[ ${output} == *"must specify a machine name"* ]]
|
||||
}
|
||||
Reference in New Issue
Block a user