github.com/makyo/juju@v0.0.0-20160425123129-2608902037e9/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  	cmdtesting "github.com/juju/juju/cmd/testing"
    10  	"github.com/juju/juju/juju/testing"
    11  	coretesting "github.com/juju/juju/testing"
    12  )
    13  
    14  func badrun(c *gc.C, exit int, args ...string) string {
    15  	args = append([]string{"juju"}, args...)
    16  	return cmdtesting.BadRun(c, exit, args...)
    17  }
    18  
    19  type CmdSuite struct {
    20  	testing.JujuConnSuite
    21  }
    22  
    23  var _ = gc.Suite(&CmdSuite{})
    24  
    25  func initSSHCommand(args ...string) (*sshCommand, error) {
    26  	com := &sshCommand{}
    27  	return com, coretesting.InitCommand(com, args)
    28  }
    29  
    30  func (*CmdSuite) TestSSHCommandInit(c *gc.C) {
    31  	// missing args
    32  	_, err := initSSHCommand()
    33  	c.Assert(err, gc.ErrorMatches, "no target name specified")
    34  }
    35  
    36  func initSCPCommand(args ...string) (*scpCommand, error) {
    37  	com := &scpCommand{}
    38  	return com, coretesting.InitCommand(com, args)
    39  }
    40  
    41  func (*CmdSuite) TestSCPCommandInit(c *gc.C) {
    42  	// missing args
    43  	_, err := initSCPCommand()
    44  	c.Assert(err, gc.ErrorMatches, "at least two arguments required")
    45  
    46  	// not enough args
    47  	_, err = initSCPCommand("mysql/0:foo")
    48  	c.Assert(err, gc.ErrorMatches, "at least two arguments required")
    49  }