當前位置: 首頁>>代碼示例>>Golang>>正文


Golang UnitPayloads.List方法代碼示例

本文整理匯總了Golang中github.com/juju/juju/payload/state.UnitPayloads.List方法的典型用法代碼示例。如果您正苦於以下問題:Golang UnitPayloads.List方法的具體用法?Golang UnitPayloads.List怎麽用?Golang UnitPayloads.List使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在github.com/juju/juju/payload/state.UnitPayloads的用法示例。


在下文中一共展示了UnitPayloads.List方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。

示例1: TestListAll

func (s *unitPayloadsSuite) TestListAll(c *gc.C) {
	id1 := "f47ac10b-58cc-4372-a567-0e02b2c3d479"
	id2 := "f47ac10b-58cc-4372-a567-0e02b2c3d480"
	pl1 := s.newPayload("docker", "payloadA/payloadA-xyz")
	pl2 := s.newPayload("docker", "payloadB/payloadB-abc")
	s.persist.setPayload(id1, &pl1)
	s.persist.setPayload(id2, &pl2)
	fpi1 := payload.FullPayloadInfo{Payload: pl1}
	fpi2 := payload.FullPayloadInfo{Payload: pl2}

	ps := state.UnitPayloads{
		Persist: s.persist,
		Unit:    "a-service/0",
	}
	results, err := ps.List()
	c.Assert(err, jc.ErrorIsNil)

	s.stub.CheckCallNames(c, "ListAll", "LookUp", "LookUp")
	c.Assert(results, gc.HasLen, 2)
	if results[0].Payload.Name == "payloadA" {
		c.Check(results[0].Payload, jc.DeepEquals, &fpi1)
		c.Check(results[1].Payload, jc.DeepEquals, &fpi2)
	} else {
		c.Check(results[0].Payload, jc.DeepEquals, &fpi2)
		c.Check(results[1].Payload, jc.DeepEquals, &fpi1)
	}
}
開發者ID:imoapps,項目名稱:juju,代碼行數:27,代碼來源:unit_test.go

示例2: TestListFailed

func (s *unitPayloadsSuite) TestListFailed(c *gc.C) {
	failure := errors.Errorf("<failed!>")
	s.stub.SetErrors(failure)

	ps := state.UnitPayloads{
		Persist: s.persist,
		Unit:    "a-service/0",
	}
	_, err := ps.List()

	s.stub.CheckCallNames(c, "ListAll")
	c.Check(errors.Cause(err), gc.Equals, failure)
}
開發者ID:imoapps,項目名稱:juju,代碼行數:13,代碼來源:unit_test.go

示例3: TestListOkay

func (s *unitPayloadsSuite) TestListOkay(c *gc.C) {
	id := "f47ac10b-58cc-4372-a567-0e02b2c3d479"
	otherID := "f47ac10b-58cc-4372-a567-0e02b2c3d480"
	pl := s.newPayload("docker", "payloadA/payloadA-xyz")
	other := s.newPayload("docker", "payloadB/payloadB-abc")
	s.persist.setPayload(id, &pl)
	s.persist.setPayload(otherID, &other)

	ps := state.UnitPayloads{
		Persist: s.persist,
		Unit:    "a-service/0",
	}
	results, err := ps.List(id)
	c.Assert(err, jc.ErrorIsNil)

	s.stub.CheckCallNames(c, "List")
	c.Check(results, jc.DeepEquals, []payload.Result{{
		ID:      id,
		Payload: &payload.FullPayloadInfo{Payload: pl},
	}})
}
開發者ID:imoapps,項目名稱:juju,代碼行數:21,代碼來源:unit_test.go

示例4: TestListMissing

func (s *unitPayloadsSuite) TestListMissing(c *gc.C) {
	missingID := "f47ac10b-58cc-4372-a567-0e02b2c3d480"
	id := "f47ac10b-58cc-4372-a567-0e02b2c3d479"
	pl := s.newPayload("docker", "payloadA/payloadA-xyz")
	s.persist.setPayload(id, &pl)

	ps := state.UnitPayloads{
		Persist: s.persist,
		Unit:    "a-service/0",
	}
	results, err := ps.List(id, missingID)
	c.Assert(err, jc.ErrorIsNil)

	c.Assert(results, gc.HasLen, 2)
	c.Check(results[1].Error, gc.NotNil)
	results[1].Error = nil
	c.Check(results, jc.DeepEquals, []payload.Result{{
		ID:      id,
		Payload: &payload.FullPayloadInfo{Payload: pl},
	}, {
		ID:       missingID,
		NotFound: true,
	}})
}
開發者ID:imoapps,項目名稱:juju,代碼行數:24,代碼來源:unit_test.go


注:本文中的github.com/juju/juju/payload/state.UnitPayloads.List方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。