func (s *StatusSuite) runTestCase(c *gc.C, tc statusTestCase) { for _, modelFlag := range s.modelFlags { fakeClient := makeFakeClient( 0*time.Second, // No API delay 5*time.Second, // 5 second test timeout tc.tags, tc.results, tc.actionsByNames, "", // No API error ) restore := s.patchAPIClient(fakeClient) defer restore() s.subcommand, _ = action.NewStatusCommandForTest(s.store) args := append([]string{modelFlag, "admin"}, tc.args...) ctx, err := testing.RunCommand(c, s.subcommand, args...) if tc.expectError == "" { c.Assert(err, jc.ErrorIsNil) } else { c.Assert(err, gc.ErrorMatches, tc.expectError) } if len(tc.results) > 0 { buf, err := cmd.DefaultFormatters["yaml"](action.ActionResultsToMap(tc.results)) c.Check(err, jc.ErrorIsNil) c.Check(ctx.Stdout.(*bytes.Buffer).String(), gc.Equals, string(buf)+"\n") c.Check(ctx.Stderr.(*bytes.Buffer).String(), gc.Equals, "") } } }
func (s *StatusSuite) SetUpTest(c *gc.C) { s.BaseActionSuite.SetUpTest(c) s.subcommand, _ = action.NewStatusCommandForTest(s.store) }