func (suite *PluginSuite) TestRunPluginWithFailing(c *C) {
	suite.makeFailingPlugin("foo", 2)
	ctx := testing.Context(c)
	err := RunPlugin(ctx, "foo", []string{"some params"})
	c.Assert(err, ErrorMatches, "exit status 2")
	c.Assert(testing.Stdout(ctx), Equals, "failing\n")
	c.Assert(testing.Stderr(ctx), Equals, "")
}
func (suite *PluginSuite) TestRunPluginExisingDashE(c *C) {
	suite.makePlugin("foo", 0755)
	ctx := testing.Context(c)
	err := RunPlugin(ctx, "foo", []string{"-e plugins-rock some params"})
	c.Assert(err, IsNil)
	c.Assert(testing.Stdout(ctx), Equals, "foo plugins-rock some params\n")
	c.Assert(testing.Stderr(ctx), Equals, "")
}
func (suite *PluginSuite) TestRunPluginExisingJujuEnv(c *C) {
	suite.makePlugin("foo", 0755)
	os.Setenv("JUJU_ENV", "omg")
	ctx := testing.Context(c)
	err := RunPlugin(ctx, "foo", []string{"some params"})
	c.Assert(err, IsNil)
	c.Assert(testing.Stdout(ctx), Equals, "foo omg some params\n")
	c.Assert(testing.Stderr(ctx), Equals, "")
}
Beispiel #4
0
func (s *RelationSetSuite) TestRunDeprecationWarning(c *C) {
	hctx := s.GetHookContext(c, 0, "")
	com, _ := jujuc.NewCommand(hctx, "relation-set")
	// The rel= is needed to make this a valid command.
	ctx, err := testing.RunCommand(c, com, []string{"--format", "foo", "rel="})

	c.Assert(err, IsNil)
	c.Assert(testing.Stdout(ctx), Equals, "")
	c.Assert(testing.Stderr(ctx), Equals, "--format flag deprecated for command \"relation-set\"")
}
Beispiel #5
0
func (s *SuperCommandSuite) TestMissingCallbackErrors(c *C) {
	callback := func(ctx *cmd.Context, subcommand string, args []string) error {
		return fmt.Errorf("command not found %q", subcommand)
	}

	ctx := testing.Context(c)
	code := cmd.Main(NewSuperWithCallback(callback), ctx, []string{"foo"})
	c.Assert(code, Equals, 1)
	c.Assert(testing.Stdout(ctx), Equals, "")
	c.Assert(testing.Stderr(ctx), Equals, "error: command not found \"foo\"\n")
}
Beispiel #6
0
func (s *SuperCommandSuite) TestMissingCallbackContextWiredIn(c *C) {
	callback := func(ctx *cmd.Context, subcommand string, args []string) error {
		fmt.Fprintf(ctx.Stdout, "this is std out")
		fmt.Fprintf(ctx.Stderr, "this is std err")
		return nil
	}

	ctx := testing.Context(c)
	code := cmd.Main(NewSuperWithCallback(callback), ctx, []string{"foo", "bar", "baz", "--debug"})
	c.Assert(code, Equals, 0)
	c.Assert(testing.Stdout(ctx), Equals, "this is std out")
	c.Assert(testing.Stderr(ctx), Equals, "this is std err")
}
Beispiel #7
0
func (s *PortsSuite) TestOpenCloseDeprecation(c *C) {
	hctx := s.GetHookContext(c, -1, "")
	for _, t := range portsFormatDeprectaionTests {
		name := t.cmd[0]
		com, err := jujuc.NewCommand(hctx, name)
		c.Assert(err, IsNil)
		ctx := testing.Context(c)
		code := cmd.Main(com, ctx, t.cmd[1:])
		c.Assert(code, Equals, 0)
		c.Assert(testing.Stdout(ctx), Equals, "")
		c.Assert(testing.Stderr(ctx), Equals, "--format flag deprecated for command \""+name+"\"")
	}
}
Beispiel #8
0
func (s *JujuLogSuite) TestLogDeprecation(c *C) {
	com := newJujuLogCommand(c)
	ctx, err := testing.RunCommand(c, com, []string{"--format", "foo", "msg"})
	c.Assert(err, IsNil)
	c.Assert(testing.Stderr(ctx), Equals, "--format flag deprecated for command \"juju-log\"")
}