本文整理汇总了Golang中github.com/juju/juju/api/imagemetadata.NewClient函数的典型用法代码示例。如果您正苦于以下问题:Golang NewClient函数的具体用法?Golang NewClient怎么用?Golang NewClient使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了NewClient函数的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: TestDeleteFailure
func (s *imagemetadataSuite) TestDeleteFailure(c *gc.C) {
called := false
msg := "save failure"
apiCaller := testing.APICallerFunc(
func(objType string,
version int,
id, request string,
a, result interface{},
) error {
called = true
c.Check(objType, gc.Equals, "ImageMetadata")
c.Check(id, gc.Equals, "")
c.Check(request, gc.Equals, "Delete")
results := result.(*params.ErrorResults)
results.Results = []params.ErrorResult{
{¶ms.Error{Message: msg}},
}
return nil
})
client := imagemetadata.NewClient(apiCaller)
err := client.Delete("tst12345")
c.Assert(err, gc.ErrorMatches, msg)
c.Assert(called, jc.IsTrue)
}
开发者ID:imoapps,项目名称:juju,代码行数:27,代码来源:client_test.go
示例2: NewImageMetadataAPI
// NewImageMetadataAPI returns a image metadata api for the root api endpoint
// that the environment command returns.
func (c *cloudImageMetadataCommandBase) NewImageMetadataAPI() (*imagemetadata.Client, error) {
root, err := c.NewAPIRoot()
if err != nil {
return nil, err
}
return imagemetadata.NewClient(root), nil
}
开发者ID:imoapps,项目名称:juju,代码行数:9,代码来源:cloudimagemetadata.go
示例3: TestDeleteMultipleResult
func (s *imagemetadataSuite) TestDeleteMultipleResult(c *gc.C) {
imageId := "tst12345"
called := false
apiCaller := testing.APICallerFunc(
func(objType string,
version int,
id, request string,
a, result interface{},
) error {
called = true
c.Check(objType, gc.Equals, "ImageMetadata")
c.Check(id, gc.Equals, "")
c.Check(request, gc.Equals, "Delete")
results := result.(*params.ErrorResults)
results.Results = []params.ErrorResult{{}, {}}
return nil
})
client := imagemetadata.NewClient(apiCaller)
err := client.Delete(imageId)
c.Assert(err, gc.ErrorMatches, regexp.QuoteMeta(`expected to find one result for image id "tst12345" but found 2`))
c.Assert(called, jc.IsTrue)
}
开发者ID:imoapps,项目名称:juju,代码行数:25,代码来源:client_test.go
示例4: TestDelete
func (s *imagemetadataSuite) TestDelete(c *gc.C) {
imageId := "tst12345"
called := false
apiCaller := testing.APICallerFunc(
func(objType string,
version int,
id, request string,
a, result interface{},
) error {
called = true
c.Check(objType, gc.Equals, "ImageMetadata")
c.Check(id, gc.Equals, "")
c.Check(request, gc.Equals, "Delete")
c.Assert(a, gc.FitsTypeOf, params.MetadataImageIds{})
c.Assert(a.(params.MetadataImageIds).Ids, gc.DeepEquals, []string{imageId})
results := result.(*params.ErrorResults)
results.Results = []params.ErrorResult{{}}
return nil
})
client := imagemetadata.NewClient(apiCaller)
err := client.Delete(imageId)
c.Check(err, jc.ErrorIsNil)
c.Assert(called, jc.IsTrue)
}
开发者ID:imoapps,项目名称:juju,代码行数:28,代码来源:client_test.go
示例5: TestSave
func (s *imagemetadataSuite) TestSave(c *gc.C) {
m := params.CloudImageMetadata{}
called := false
apiCaller := testing.APICallerFunc(
func(objType string,
version int,
id, request string,
a, result interface{},
) error {
called = true
c.Check(objType, gc.Equals, "ImageMetadata")
c.Check(id, gc.Equals, "")
c.Check(request, gc.Equals, "Save")
c.Assert(a, gc.FitsTypeOf, params.MetadataSaveParams{})
args := a.(params.MetadataSaveParams)
c.Assert(args.Metadata, gc.HasLen, 1)
c.Assert(args.Metadata, jc.DeepEquals, []params.CloudImageMetadataList{
{[]params.CloudImageMetadata{m, m}},
})
c.Assert(result, gc.FitsTypeOf, ¶ms.ErrorResults{})
*(result.(*params.ErrorResults)) = params.ErrorResults{
Results: []params.ErrorResult{{}},
}
return nil
})
client := imagemetadata.NewClient(apiCaller)
err := client.Save([]params.CloudImageMetadata{m, m})
c.Check(err, jc.ErrorIsNil)
c.Assert(called, jc.IsTrue)
}
开发者ID:imoapps,项目名称:juju,代码行数:35,代码来源:client_test.go
示例6: ImageClient
func (s *baseMetadataSuite) ImageClient(done chan struct{}) *imagemetadata.Client {
closer := apitesting.APICallerFunc(func(objType string, version int, id, request string, a, result interface{}) error {
s.apiCalled = false
if request == "UpdateFromPublishedImages" {
s.apiCalled = true
close(done)
return nil
}
return nil
})
return imagemetadata.NewClient(closer)
}
开发者ID:howbazaar,项目名称:juju,代码行数:13,代码来源:package_test.go
示例7: TestSaveFacadeCallError
func (s *imagemetadataSuite) TestSaveFacadeCallError(c *gc.C) {
m := []params.CloudImageMetadata{{}}
msg := "facade failure"
apiCaller := testing.APICallerFunc(
func(objType string,
version int,
id, request string,
a, result interface{},
) error {
c.Check(objType, gc.Equals, "ImageMetadata")
c.Check(id, gc.Equals, "")
c.Check(request, gc.Equals, "Save")
return errors.New(msg)
})
client := imagemetadata.NewClient(apiCaller)
err := client.Save(m)
c.Assert(errors.Cause(err), gc.ErrorMatches, msg)
}
开发者ID:imoapps,项目名称:juju,代码行数:18,代码来源:client_test.go
示例8: TestUpdateFromPublishedImagesFacadeCallError
func (s *imagemetadataSuite) TestUpdateFromPublishedImagesFacadeCallError(c *gc.C) {
called := false
msg := "facade failure"
apiCaller := testing.APICallerFunc(
func(objType string,
version int,
id, request string,
a, result interface{},
) error {
called = true
c.Check(objType, gc.Equals, "ImageMetadata")
c.Check(id, gc.Equals, "")
c.Check(request, gc.Equals, "UpdateFromPublishedImages")
return errors.New(msg)
})
client := imagemetadata.NewClient(apiCaller)
err := client.UpdateFromPublishedImages()
c.Assert(errors.Cause(err), gc.ErrorMatches, msg)
c.Assert(called, jc.IsTrue)
}
开发者ID:kakamessi99,项目名称:juju,代码行数:20,代码来源:client_test.go
示例9: TestUpdateFromPublishedImages
func (s *imagemetadataSuite) TestUpdateFromPublishedImages(c *gc.C) {
called := false
apiCaller := testing.APICallerFunc(
func(objType string,
version int,
id, request string,
a, result interface{},
) error {
called = true
c.Check(objType, gc.Equals, "ImageMetadata")
c.Check(id, gc.Equals, "")
c.Check(request, gc.Equals, "UpdateFromPublishedImages")
return nil
})
client := imagemetadata.NewClient(apiCaller)
err := client.UpdateFromPublishedImages()
c.Check(err, jc.ErrorIsNil)
c.Assert(called, jc.IsTrue)
}
开发者ID:kakamessi99,项目名称:juju,代码行数:21,代码来源:client_test.go
示例10: TestListFacadeCallError
func (s *imagemetadataSuite) TestListFacadeCallError(c *gc.C) {
msg := "facade failure"
called := false
apiCaller := testing.APICallerFunc(
func(objType string,
version int,
id, request string,
a, result interface{},
) error {
called = true
c.Check(objType, gc.Equals, "ImageMetadata")
c.Check(id, gc.Equals, "")
c.Check(request, gc.Equals, "List")
return errors.New(msg)
})
client := imagemetadata.NewClient(apiCaller)
found, err := client.List("", "", nil, nil, "", "")
c.Assert(errors.Cause(err), gc.ErrorMatches, msg)
c.Assert(found, gc.HasLen, 0)
c.Assert(called, jc.IsTrue)
}
开发者ID:kakamessi99,项目名称:juju,代码行数:22,代码来源:client_test.go
示例11: TestSave
func (s *imagemetadataSuite) TestSave(c *gc.C) {
m := params.CloudImageMetadata{}
called := false
msg := "save failure"
expected := []params.ErrorResult{
params.ErrorResult{},
params.ErrorResult{¶ms.Error{Message: msg}},
}
apiCaller := testing.APICallerFunc(
func(objType string,
version int,
id, request string,
a, result interface{},
) error {
called = true
c.Check(objType, gc.Equals, "ImageMetadata")
c.Check(id, gc.Equals, "")
c.Check(request, gc.Equals, "Save")
args, ok := a.(params.MetadataSaveParams)
c.Assert(ok, jc.IsTrue)
c.Assert(args.Metadata, gc.HasLen, 2)
c.Assert(args.Metadata, gc.DeepEquals, []params.CloudImageMetadata{m, m})
if results, k := result.(*params.ErrorResults); k {
results.Results = expected
}
return nil
})
client := imagemetadata.NewClient(apiCaller)
errs, err := client.Save([]params.CloudImageMetadata{m, m})
c.Check(err, jc.ErrorIsNil)
c.Assert(called, jc.IsTrue)
c.Assert(errs, jc.DeepEquals, expected)
}
开发者ID:kakamessi99,项目名称:juju,代码行数:39,代码来源:client_test.go
示例12: SetUpTest
func (s *cloudImageMetadataSuite) SetUpTest(c *gc.C) {
s.JujuConnSuite.SetUpTest(c)
s.client = imagemetadata.NewClient(s.APIState)
c.Assert(s.client, gc.NotNil)
}
开发者ID:ktsakalozos,项目名称:juju,代码行数:6,代码来源:cloudimagemetadata_test.go
示例13: TestList
func (s *imagemetadataSuite) TestList(c *gc.C) {
// setup data for test
imageId := "imageid"
stream := "stream"
region := "region"
series := "series"
arch := "arch"
virtType := "virt-type"
rootStorageType := "root-storage-type"
rootStorageSize := uint64(1024)
source := "source"
called := false
apiCaller := testing.APICallerFunc(
func(objType string,
version int,
id, request string,
a, result interface{},
) error {
called = true
c.Check(objType, gc.Equals, "ImageMetadata")
c.Check(id, gc.Equals, "")
c.Check(request, gc.Equals, "List")
args, ok := a.(params.ImageMetadataFilter)
c.Assert(ok, jc.IsTrue)
if results, k := result.(*params.ListCloudImageMetadataResult); k {
instances := []params.CloudImageMetadata{
params.CloudImageMetadata{
ImageId: imageId,
Stream: args.Stream,
Region: args.Region,
Series: args.Series[0],
Arch: args.Arches[0],
VirtType: args.VirtType,
RootStorageType: args.RootStorageType,
RootStorageSize: &rootStorageSize,
Source: source,
},
}
results.Result = instances
}
return nil
})
client := imagemetadata.NewClient(apiCaller)
found, err := client.List(
stream, region,
[]string{series}, []string{arch},
virtType, rootStorageType,
)
c.Check(err, jc.ErrorIsNil)
c.Assert(called, jc.IsTrue)
expected := []params.CloudImageMetadata{
params.CloudImageMetadata{
ImageId: imageId,
Stream: stream,
Region: region,
Series: series,
Arch: arch,
VirtType: virtType,
RootStorageType: rootStorageType,
RootStorageSize: &rootStorageSize,
Source: source,
},
}
c.Assert(found, jc.DeepEquals, expected)
}
开发者ID:kakamessi99,项目名称:juju,代码行数:70,代码来源:client_test.go
示例14: MetadataUpdater
// MetadataUpdater returns access to the imageMetadata API
func (st *state) MetadataUpdater() *imagemetadata.Client {
return imagemetadata.NewClient(st)
}
开发者ID:snailwalker,项目名称:juju,代码行数:4,代码来源:state.go
注:本文中的github.com/juju/juju/api/imagemetadata.NewClient函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论