github.com/axw/juju@v0.0.0-20161005053422-4bd6544d08d4/cmd/juju/backups/list_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/cmd/cmdtesting" 9 "github.com/juju/errors" 10 jc "github.com/juju/testing/checkers" 11 gc "gopkg.in/check.v1" 12 13 "github.com/juju/juju/cmd/juju/backups" 14 "github.com/juju/juju/testing" 15 ) 16 17 type listSuite struct { 18 BaseBackupsSuite 19 subcommand cmd.Command 20 } 21 22 var _ = gc.Suite(&listSuite{}) 23 24 func (s *listSuite) SetUpTest(c *gc.C) { 25 s.BaseBackupsSuite.SetUpTest(c) 26 s.subcommand = backups.NewListCommandForTest() 27 } 28 29 func (s *listSuite) TestOkay(c *gc.C) { 30 s.setSuccess() 31 ctx := cmdtesting.Context(c) 32 ctx, err := testing.RunCommand(c, s.subcommand, []string{"--verbose"}...) 33 c.Assert(err, jc.ErrorIsNil) 34 35 out := MetaResultString 36 s.checkStd(c, ctx, out, "") 37 } 38 39 func (s *listSuite) TestBrief(c *gc.C) { 40 s.setSuccess() 41 ctx, err := testing.RunCommand(c, s.subcommand) 42 c.Assert(err, jc.ErrorIsNil) 43 out := s.metaresult.ID + "\n" 44 s.checkStd(c, ctx, out, "") 45 } 46 47 func (s *listSuite) TestError(c *gc.C) { 48 s.setFailure("failed!") 49 _, err := testing.RunCommand(c, s.subcommand) 50 c.Check(errors.Cause(err), gc.ErrorMatches, "failed!") 51 }