當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。