コード例 #1
0
ファイル: api_test.go プロジェクト: juju/romulus
func (s *clientSuite) SetUpTest(c *gc.C) {
	s.httpClient = &mockHttpClient{}

	client, err := api.NewClient(api.HTTPClient(s.httpClient))
	c.Assert(err, jc.ErrorIsNil)
	s.client = client

}
コード例 #2
0
ファイル: api_test.go プロジェクト: juju/romulus
func (s *clientSuite) TestBaseURL(c *gc.C) {
	client, err := api.NewClient(api.HTTPClient(s.httpClient), api.BaseURL("https://example.com"))
	c.Assert(err, jc.ErrorIsNil)

	s.httpClient.status = http.StatusNotFound
	_, err = client.GetAssociatedPlans("bob/uptime")
	c.Assert(err, gc.ErrorMatches, `failed to retrieve associated plans: received http response:  - code "Not Found"`)
	s.httpClient.CheckCall(c, 0, "Do", "https://example.com/charm?charm-url=bob%2Fuptime")
	s.httpClient.ResetCalls()

	m, err := macaroon.New(nil, "", "")
	c.Assert(err, jc.ErrorIsNil)
	data, err := json.Marshal(m)
	c.Assert(err, jc.ErrorIsNil)

	s.httpClient.status = http.StatusOK
	s.httpClient.body = data
	_, err = client.Authorize(utils.MustNewUUID().String(), "cs:trusty/test-charm-0", "test-charm", utils.MustNewUUID().String(), nil)
	c.Assert(err, jc.ErrorIsNil)
	s.httpClient.CheckCall(c, 0, "DoWithBody", "https://example.com/plan/authorize")
}
コード例 #3
0
ファイル: list_plans.go プロジェクト: alesstimec/romulus-1
	"gopkg.in/yaml.v2"
	"launchpad.net/gnuflag"

	api "github.com/juju/romulus/api/plan"
	rcmd "github.com/juju/romulus/cmd"
	wireformat "github.com/juju/romulus/wireformat/plan"
)

// apiClient defines the interface of the plan api client need by this command.
type apiClient interface {
	// GetAssociatedPlans returns the plans associated with the charm.
	GetAssociatedPlans(charmURL string) ([]wireformat.Plan, error)
}

var newClient = func(client *httpbakery.Client) (apiClient, error) {
	return api.NewClient(api.HTTPClient(client))
}

const listPlansDoc = `
List plans available for the specified charm.

Examples:
    juju plans cs:webapp
`

// ListPlansCommand retrieves plans that are available for the specified charm
type ListPlansCommand struct {
	modelcmd.JujuCommandBase

	out      cmd.Output
	CharmURL string