func (s *ShowOutputSuite) TestInit(c *gc.C) { tests := []struct { should string args []string expectError string }{{ should: "fail with missing arg", args: []string{}, expectError: "no action ID specified", }, { should: "fail with multiple args", args: []string{"12345", "54321"}, expectError: `unrecognized args: \["54321"\]`, }} for i, t := range tests { for _, modelFlag := range s.modelFlags { c.Logf("test %d: it should %s: juju show-action-output %s", i, t.should, strings.Join(t.args, " ")) cmd, _ := action.NewShowOutputCommandForTest(s.store) args := append([]string{modelFlag, "admin"}, t.args...) err := testing.InitCommand(cmd, args) if t.expectError != "" { c.Check(err, gc.ErrorMatches, t.expectError) } } } }
func testRunHelper(c *gc.C, s *ShowOutputSuite, client *fakeAPIClient, expectedErr, expectedOutput, wait, query, modelFlag string) { unpatch := s.BaseActionSuite.patchAPIClient(client) defer unpatch() args := append([]string{modelFlag, "admin"}, query) if wait != "" { args = append(args, "--wait", wait) } cmd, _ := action.NewShowOutputCommandForTest(s.store) ctx, err := testing.RunCommand(c, cmd, args...) if expectedErr != "" { c.Check(err, gc.ErrorMatches, expectedErr) } else { c.Assert(err, gc.IsNil) c.Check(ctx.Stdout.(*bytes.Buffer).String(), gc.Equals, expectedOutput) } }