github.com/axw/juju@v0.0.0-20161005053422-4bd6544d08d4/cmd/juju/commands/cmd_test.go (about)

     1  // Copyright 2012, 2013 Canonical Ltd.
     2  // Licensed under the AGPLv3, see LICENCE file for details.
     3  
     4  package commands
     5  
     6  import (
     7  	gc "gopkg.in/check.v1"
     8  
     9  	"github.com/juju/testing"
    10  
    11  	cmdtesting "github.com/juju/juju/cmd/testing"
    12  	coretesting "github.com/juju/juju/testing"
    13  )
    14  
    15  func badrun(c *gc.C, exit int, args ...string) string {
    16  	args = append([]string{"juju"}, args...)
    17  	return cmdtesting.BadRun(c, exit, args...)
    18  }
    19  
    20  type CmdSuite struct {
    21  	testing.IsolationSuite
    22  }
    23  
    24  var _ = gc.Suite(&CmdSuite{})
    25  
    26  func initSSHCommand(args ...string) (*sshCommand, error) {
    27  	com := &sshCommand{}
    28  	return com, coretesting.InitCommand(com, args)
    29  }
    30  
    31  func (*CmdSuite) TestSSHCommandInit(c *gc.C) {
    32  	// missing args
    33  	_, err := initSSHCommand()
    34  	c.Assert(err, gc.ErrorMatches, "no target name specified")
    35  }
    36  
    37  func initSCPCommand(args ...string) (*scpCommand, error) {
    38  	com := &scpCommand{}
    39  	return com, coretesting.InitCommand(com, args)
    40  }
    41  
    42  func (*CmdSuite) TestSCPCommandInit(c *gc.C) {
    43  	// missing args
    44  	_, err := initSCPCommand()
    45  	c.Assert(err, gc.ErrorMatches, "at least two arguments required")
    46  
    47  	// not enough args
    48  	_, err = initSCPCommand("mysql/0:foo")
    49  	c.Assert(err, gc.ErrorMatches, "at least two arguments required")
    50  }