Example #1
0
func (s *FetchSuite) 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 actions fetch %s", i,
				t.should, strings.Join(t.args, " "))
			cmd, _ := action.NewFetchCommand(s.store)
			args := append([]string{modelFlag, "admin"}, t.args...)
			err := testing.InitCommand(cmd, args)
			if t.expectError != "" {
				c.Check(err, gc.ErrorMatches, t.expectError)
			}
		}
	}
}
Example #2
0
func testRunHelper(c *gc.C, s *FetchSuite, 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.NewFetchCommand(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)
	}
}
Example #3
0
func (s *FetchSuite) TestHelp(c *gc.C) {
	cmd, _ := action.NewFetchCommand(s.store)
	s.checkHelp(c, cmd)
}