• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Golang state.UnitPayloads类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Golang中github.com/juju/juju/payload/state.UnitPayloads的典型用法代码示例。如果您正苦于以下问题:Golang UnitPayloads类的具体用法?Golang UnitPayloads怎么用?Golang UnitPayloads使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了UnitPayloads类的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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: TestSetStatusMissing

func (s *unitPayloadsSuite) TestSetStatusMissing(c *gc.C) {
	id := "f47ac10b-58cc-4372-a567-0e02b2c3d479"
	ps := state.UnitPayloads{
		Persist: s.persist,
		Unit:    "a-service/0",
	}
	err := ps.SetStatus(id, payload.StateRunning)

	c.Check(err, jc.Satisfies, errors.IsNotFound)
}
开发者ID:imoapps,项目名称:juju,代码行数:10,代码来源:unit_test.go


示例3: TestUntrackMissing

func (s *unitPayloadsSuite) TestUntrackMissing(c *gc.C) {
	id := "f47ac10b-58cc-4372-a567-0e02b2c3d479"
	ps := state.UnitPayloads{
		Persist: s.persist,
		Unit:    "a-service/0",
	}
	err := ps.Untrack(id)
	c.Assert(err, jc.ErrorIsNil)

	s.stub.CheckCallNames(c, "Untrack")
	c.Check(s.persist.payloads, gc.HasLen, 0)
}
开发者ID:imoapps,项目名称:juju,代码行数:12,代码来源:unit_test.go


示例4: 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


示例5: TestTrackInvalid

func (s *unitPayloadsSuite) TestTrackInvalid(c *gc.C) {
	s.id = "f47ac10b-58cc-4372-a567-0e02b2c3d479"
	pl := s.newPayload("", "payloadA/payloadA-xyz")

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

	err := ps.Track(pl)

	c.Check(err, jc.Satisfies, errors.IsNotValid)
}
开发者ID:imoapps,项目名称:juju,代码行数:14,代码来源:unit_test.go


示例6: TestUntrackFailed

func (s *unitPayloadsSuite) TestUntrackFailed(c *gc.C) {
	id := "f47ac10b-58cc-4372-a567-0e02b2c3d479"
	failure := errors.Errorf("<failed!>")
	s.stub.SetErrors(failure)

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

	s.stub.CheckCallNames(c, "Untrack")
	c.Check(errors.Cause(err), gc.Equals, failure)
}
开发者ID:imoapps,项目名称:juju,代码行数:14,代码来源:unit_test.go


示例7: TestUntrackOkay

func (s *unitPayloadsSuite) TestUntrackOkay(c *gc.C) {
	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",
	}
	err := ps.Untrack(id)
	c.Assert(err, jc.ErrorIsNil)

	s.stub.CheckCallNames(c, "Untrack")
	c.Check(s.persist.payloads, gc.HasLen, 0)
}
开发者ID:imoapps,项目名称:juju,代码行数:15,代码来源:unit_test.go


示例8: TestSetStatusFailed

func (s *unitPayloadsSuite) TestSetStatusFailed(c *gc.C) {
	id := "f47ac10b-58cc-4372-a567-0e02b2c3d479"
	failure := errors.Errorf("<failed!>")
	s.stub.SetErrors(failure)
	pl := s.newPayload("docker", "payloadA/payloadA-xyz")
	s.persist.setPayload(id, &pl)

	ps := state.UnitPayloads{
		Persist: s.persist,
		Unit:    "a-service/0",
	}
	err := ps.SetStatus(id, payload.StateRunning)

	c.Check(errors.Cause(err), gc.Equals, failure)
}
开发者ID:imoapps,项目名称:juju,代码行数:15,代码来源:unit_test.go


示例9: TestTrackInsertFailed

func (s *unitPayloadsSuite) TestTrackInsertFailed(c *gc.C) {
	s.id = "f47ac10b-58cc-4372-a567-0e02b2c3d479"
	failure := errors.Errorf("<failed!>")
	s.stub.SetErrors(failure)
	pl := s.newPayload("docker", "payloadA/payloadA-xyz")

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

	err := ps.Track(pl)

	c.Check(errors.Cause(err), gc.Equals, failure)
}
开发者ID:imoapps,项目名称:juju,代码行数:16,代码来源:unit_test.go


示例10: TestTrackOkay

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

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

	err := ps.Track(pl)
	c.Assert(err, jc.ErrorIsNil)

	s.stub.CheckCallNames(c, "newID", "Track")
	c.Check(s.persist.payloads, gc.HasLen, 1)
	s.persist.checkPayload(c, s.id, pl)
}
开发者ID:imoapps,项目名称:juju,代码行数:17,代码来源:unit_test.go


示例11: TestSetStatusOkay

func (s *unitPayloadsSuite) TestSetStatusOkay(c *gc.C) {
	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",
	}

	err := ps.SetStatus(id, payload.StateRunning)
	c.Assert(err, jc.ErrorIsNil)

	s.stub.CheckCallNames(c, "SetStatus")
	current := s.persist.payloads[id]
	c.Check(current.Status, jc.DeepEquals, payload.StateRunning)
}
开发者ID:imoapps,项目名称:juju,代码行数:17,代码来源:unit_test.go


示例12: 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


示例13: 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类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Golang status.ListCommand类代码示例发布时间:2022-05-23
下一篇:
Golang payload.Payload类代码示例发布时间:2022-05-23
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap