本文整理汇总了Golang中github.com/juju/juju/resource.ServiceResources.Updates方法的典型用法代码示例。如果您正苦于以下问题:Golang ServiceResources.Updates方法的具体用法?Golang ServiceResources.Updates怎么用?Golang ServiceResources.Updates使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/juju/juju/resource.ServiceResources
的用法示例。
在下文中一共展示了ServiceResources.Updates方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: TestUpdatesUploaded
func (s *ServiceResourcesSuite) TestUpdatesUploaded(c *gc.C) {
csRes := newStoreResource(c, "spam", "a-service", 2)
res := csRes // a copy
res.Origin = charmresource.OriginUpload
sr := resource.ServiceResources{
Resources: []resource.Resource{
res,
},
CharmStoreResources: []charmresource.Resource{
csRes.Resource,
},
}
updates, err := sr.Updates()
c.Assert(err, jc.ErrorIsNil)
c.Check(updates, gc.HasLen, 0)
}
示例2: TestUpdatesNone
func (s *ServiceResourcesSuite) TestUpdatesNone(c *gc.C) {
spam := newStoreResource(c, "spam", "a-service", 2)
eggs := newStoreResource(c, "eggs", "a-service", 3)
sr := resource.ServiceResources{
Resources: []resource.Resource{
spam,
eggs,
},
CharmStoreResources: []charmresource.Resource{
spam.Resource,
eggs.Resource,
},
}
updates, err := sr.Updates()
c.Assert(err, jc.ErrorIsNil)
c.Check(updates, gc.HasLen, 0)
}
示例3: formatServiceResources
func formatServiceResources(sr resource.ServiceResources) (FormattedServiceInfo, error) {
var formatted FormattedServiceInfo
updates, err := sr.Updates()
if err != nil {
return formatted, errors.Trace(err)
}
formatted = FormattedServiceInfo{
Resources: make([]FormattedSvcResource, len(sr.Resources)),
Updates: make([]FormattedCharmResource, len(updates)),
}
for i, r := range sr.Resources {
formatted.Resources[i] = FormatSvcResource(r)
}
for i, u := range updates {
formatted.Updates[i] = FormatCharmResource(u)
}
return formatted, nil
}
示例4: FormatServiceDetails
// FormatServiceDetails converts a ServiceResources value into a formatted value
// for display on the command line.
func FormatServiceDetails(sr resource.ServiceResources) (FormattedServiceDetails, error) {
var formatted FormattedServiceDetails
details, err := detailedResources("", sr)
if err != nil {
return formatted, errors.Trace(err)
}
updates, err := sr.Updates()
if err != nil {
return formatted, errors.Trace(err)
}
formatted = FormattedServiceDetails{
Resources: details,
Updates: make([]FormattedCharmResource, len(updates)),
}
for i, u := range updates {
formatted.Updates[i] = FormatCharmResource(u)
}
return formatted, nil
}
示例5: TestUpdatesBadOrdering
func (s *ServiceResourcesSuite) TestUpdatesBadOrdering(c *gc.C) {
spam := newStoreResource(c, "spam", "a-service", 2)
eggs := newStoreResource(c, "eggs", "a-service", 3)
expected := eggs.Resource
expected.Revision += 1
sr := resource.ServiceResources{
Resources: []resource.Resource{
spam,
eggs,
},
CharmStoreResources: []charmresource.Resource{
expected,
spam.Resource,
},
}
updates, err := sr.Updates()
c.Assert(err, jc.ErrorIsNil)
c.Check(updates, jc.DeepEquals, []charmresource.Resource{expected})
}