当前位置: 首页>>代码示例>>Golang>>正文


Golang ServiceResources.Updates方法代码示例

本文整理汇总了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)
}
开发者ID:AlexisBruemmer,项目名称:juju,代码行数:18,代码来源:service_test.go

示例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)
}
开发者ID:AlexisBruemmer,项目名称:juju,代码行数:19,代码来源:service_test.go

示例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
}
开发者ID:AlexisBruemmer,项目名称:juju,代码行数:19,代码来源:formatter.go

示例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
}
开发者ID:AlexisBruemmer,项目名称:juju,代码行数:21,代码来源:formatter.go

示例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})
}
开发者ID:AlexisBruemmer,项目名称:juju,代码行数:21,代码来源:service_test.go


注:本文中的github.com/juju/juju/resource.ServiceResources.Updates方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。