github.com/makyo/juju@v0.0.0-20160425123129-2608902037e9/cmd/juju/backups/remove_test.go (about)

     1  // Copyright 2014 Canonical Ltd.
     2  // Licensed under the AGPLv3, see LICENCE file for details.
     3  
     4  package backups_test
     5  
     6  import (
     7  	"github.com/juju/cmd"
     8  	"github.com/juju/errors"
     9  	jc "github.com/juju/testing/checkers"
    10  	gc "gopkg.in/check.v1"
    11  
    12  	"github.com/juju/juju/cmd/juju/backups"
    13  	"github.com/juju/juju/testing"
    14  )
    15  
    16  type removeSuite struct {
    17  	BaseBackupsSuite
    18  	command cmd.Command
    19  }
    20  
    21  var _ = gc.Suite(&removeSuite{})
    22  
    23  func (s *removeSuite) SetUpTest(c *gc.C) {
    24  	s.BaseBackupsSuite.SetUpTest(c)
    25  	s.command = backups.NewRemoveCommandForTest()
    26  }
    27  
    28  func (s *removeSuite) TestOkay(c *gc.C) {
    29  	s.setSuccess()
    30  	ctx, err := testing.RunCommand(c, s.command, "spam")
    31  	c.Check(err, jc.ErrorIsNil)
    32  
    33  	out := "successfully removed: spam\n"
    34  	s.checkStd(c, ctx, out, "")
    35  }
    36  
    37  func (s *removeSuite) TestError(c *gc.C) {
    38  	s.setFailure("failed!")
    39  	_, err := testing.RunCommand(c, s.command, "spam")
    40  	c.Check(errors.Cause(err), gc.ErrorMatches, "failed!")
    41  }