~juju/juju-core/trunk

« back to all changes in this revision

Viewing changes to worker/uniter/jujuc/ports_test.go

  • Committer: Tim Penhey
  • Date: 2013-03-14 22:05:40 UTC
  • mfrom: (993.1.10 format-flag)
  • Revision ID: tim.penhey@canonical.com-20130314220540-0o7j2ki1kb46sjp6
Add a --format flag for jujuc commands missing it

Fixes lp:1129130.  Also marks the --format flag as deprecated for commands
that don't produce output.

R=dfc, dimitern
CC=
https://codereview.appspot.com/7795045

Show diffs side-by-side

added added

removed removed

Lines of Context:
82
82
purpose: ensure a port is always closed
83
83
`[1:])
84
84
}
 
85
 
 
86
// Since the deprecation warning gets output during Run, we really need
 
87
// some valid commands to run
 
88
var portsFormatDeprectaionTests = []struct {
 
89
        cmd []string
 
90
}{
 
91
        {[]string{"open-port", "--format", "foo", "80"}},
 
92
        {[]string{"close-port", "--format", "foo", "80/TCP"}},
 
93
}
 
94
 
 
95
func (s *PortsSuite) TestOpenCloseDeprecation(c *C) {
 
96
        hctx := s.GetHookContext(c, -1, "")
 
97
        for _, t := range portsFormatDeprectaionTests {
 
98
                name := t.cmd[0]
 
99
                com, err := jujuc.NewCommand(hctx, name)
 
100
                c.Assert(err, IsNil)
 
101
                ctx := testing.Context(c)
 
102
                code := cmd.Main(com, ctx, t.cmd[1:])
 
103
                c.Assert(code, Equals, 0)
 
104
                c.Assert(testing.Stdout(ctx), Equals, "")
 
105
                c.Assert(testing.Stderr(ctx), Equals, "--format flag deprecated for command \""+name+"\"")
 
106
        }
 
107
}