本文整理匯總了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})
}