コード例 #1
0
func (s *DiscoverSpacesSuite) TestNewAPI(c *gc.C) {
	var called int
	apiCaller := clientErrorAPICaller(c, "ListSpaces", nil, &called)
	api := discoverspaces.NewAPI(apiCaller)
	c.Check(api, gc.NotNil)
	c.Check(called, gc.Equals, 0)

	// Make a call so that an error will be returned.
	_, err := api.ListSpaces()
	c.Assert(err, gc.ErrorMatches, "client error!")
	c.Assert(called, gc.Equals, 1)
}
コード例 #2
0
func (s *DiscoverSpacesSuite) TestListSpaces(c *gc.C) {
	var called int
	expectedResult := params.DiscoverSpacesResults{
		Results: []params.ProviderSpace{{Name: "foobar"}},
	}
	apiCaller := successAPICaller(c, "ListSpaces", nil, expectedResult, &called)
	api := discoverspaces.NewAPI(apiCaller)

	result, err := api.ListSpaces()
	c.Assert(err, jc.ErrorIsNil)
	c.Assert(result, jc.DeepEquals, expectedResult)
	c.Assert(called, gc.Equals, 1)
}
コード例 #3
0
func (s *DiscoverSpacesSuite) TestModelConfig(c *gc.C) {
	var called int
	cfg, err := config.New(config.UseDefaults, coretesting.FakeConfig())
	c.Assert(err, jc.ErrorIsNil)
	expectedResult := params.ModelConfigResult{
		Config: cfg.AllAttrs(),
	}
	apiCaller := successAPICaller(c, "ModelConfig", nil, expectedResult, &called)
	api := discoverspaces.NewAPI(apiCaller)

	result, err := api.ModelConfig()
	c.Assert(err, jc.ErrorIsNil)
	c.Assert(result, jc.DeepEquals, cfg)
	c.Assert(called, gc.Equals, 1)
}
コード例 #4
0
func (s *DiscoverSpacesSuite) TestCreateSpaces(c *gc.C) {
	var called int
	expectedResult := params.ErrorResults{
		Results: []params.ErrorResult{{}},
	}
	expectedArgs := params.CreateSpacesParams{
		Spaces: []params.CreateSpaceParams{{SpaceTag: "foo"}},
	}
	apiCaller := successAPICaller(c, "CreateSpaces", expectedArgs, expectedResult, &called)
	api := discoverspaces.NewAPI(apiCaller)

	result, err := api.CreateSpaces(expectedArgs)
	c.Assert(err, jc.ErrorIsNil)
	c.Assert(result, jc.DeepEquals, expectedResult)
	c.Assert(called, gc.Equals, 1)
}
コード例 #5
0
func (s *DiscoverSpacesSuite) TestNewAPIWithNilCaller(c *gc.C) {
	panicFunc := func() { discoverspaces.NewAPI(nil) }
	c.Assert(panicFunc, gc.PanicMatches, "caller is nil")
}
コード例 #6
0
ファイル: state.go プロジェクト: makyo/juju
// DiscoverSpaces returns access to the DiscoverSpacesAPI.
func (st *state) DiscoverSpaces() *discoverspaces.API {
	return discoverspaces.NewAPI(st)
}
コード例 #7
0
ファイル: manifold.go プロジェクト: bac/juju
func NewFacade(apiCaller base.APICaller) (Facade, error) {
	return discoverspaces.NewAPI(apiCaller), nil
}