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

Golang util.Housing类代码示例

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

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



在下文中一共展示了Housing类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。

示例1: TestOccupyLocked

func (*HousingSuite) TestOccupyLocked(c *gc.C) {
	manifold := util.Housing{
		Occupy: "fortress",
	}.Decorate(dependency.Manifold{})
	abort := make(chan struct{})
	context := dt.StubContext(abort, map[string]interface{}{
		"fortress": newGuest(false),
	})

	// start the start func
	started := make(chan struct{})
	go func() {
		defer close(started)
		worker, err := manifold.Start(context)
		c.Check(worker, gc.IsNil)
		c.Check(errors.Cause(err), gc.Equals, fortress.ErrAborted)
	}()

	// check it's blocked...
	select {
	case <-time.After(coretesting.ShortWait):
	case <-started:
		c.Errorf("Start finished early")
	}

	// ...until the context is aborted.
	close(abort)
	select {
	case <-started:
	case <-time.After(coretesting.LongWait):
		c.Fatalf("timed out")
	}
}
开发者ID:makyo,项目名称:juju,代码行数:33,代码来源:housing_test.go


示例2: TestOccupyBadType

func (*HousingSuite) TestOccupyBadType(c *gc.C) {
	manifold := util.Housing{
		Occupy: "fortress",
	}.Decorate(dependency.Manifold{})
	context := dt.StubContext(nil, map[string]interface{}{
		"fortress": false,
	})

	worker, err := manifold.Start(context)
	c.Check(worker, gc.IsNil)
	c.Check(err, gc.ErrorMatches, "cannot set false into .*")
}
开发者ID:makyo,项目名称:juju,代码行数:12,代码来源:housing_test.go


示例3: TestOccupyMissing

func (*HousingSuite) TestOccupyMissing(c *gc.C) {
	manifold := util.Housing{
		Occupy: "fortress",
	}.Decorate(dependency.Manifold{})
	context := dt.StubContext(nil, map[string]interface{}{
		"fortress": dependency.ErrMissing,
	})

	worker, err := manifold.Start(context)
	c.Check(worker, gc.IsNil)
	c.Check(errors.Cause(err), gc.Equals, dependency.ErrMissing)
}
开发者ID:makyo,项目名称:juju,代码行数:12,代码来源:housing_test.go


示例4: TestFlagBadValue

func (*HousingSuite) TestFlagBadValue(c *gc.C) {
	manifold := util.Housing{
		Flags: []string{"flag"},
	}.Decorate(dependency.Manifold{})
	context := dt.StubContext(nil, map[string]interface{}{
		"flag": flag{false},
	})

	worker, err := manifold.Start(context)
	c.Check(worker, gc.IsNil)
	c.Check(errors.Cause(err), gc.Equals, dependency.ErrMissing)
}
开发者ID:makyo,项目名称:juju,代码行数:12,代码来源:housing_test.go


示例5: TestFlagBlocksOccupy

func (*HousingSuite) TestFlagBlocksOccupy(c *gc.C) {
	manifold := util.Housing{
		Flags:  []string{"flag"},
		Occupy: "fortress",
	}.Decorate(dependency.Manifold{})
	context := dt.StubContext(nil, map[string]interface{}{
		"flag":     dependency.ErrMissing,
		"fortress": errors.New("never happen"),
	})

	worker, err := manifold.Start(context)
	c.Check(worker, gc.IsNil)
	c.Check(errors.Cause(err), gc.Equals, dependency.ErrMissing)
}
开发者ID:makyo,项目名称:juju,代码行数:14,代码来源:housing_test.go


示例6: TestReplacesFilter

func (*HousingSuite) TestReplacesFilter(c *gc.C) {
	expectIn := errors.New("tweedledum")
	expectOut := errors.New("tweedledee")
	manifold := util.Housing{
		Filter: func(in error) error {
			c.Check(in, gc.Equals, expectIn)
			return expectOut
		},
	}.Decorate(dependency.Manifold{
		Filter: panicFilter,
	})

	out := manifold.Filter(expectIn)
	c.Check(out, gc.Equals, expectOut)
}
开发者ID:makyo,项目名称:juju,代码行数:15,代码来源:housing_test.go


示例7: TestOccupySuccess

func (*HousingSuite) TestOccupySuccess(c *gc.C) {
	expectWorker := workertest.NewErrorWorker(errors.New("ignored"))
	defer workertest.DirtyKill(c, expectWorker)
	manifold := util.Housing{
		Occupy: "fortress",
	}.Decorate(dependency.Manifold{
		Start: func(dependency.Context) (worker.Worker, error) {
			return expectWorker, nil
		},
	})
	guest := newGuest(true)
	context := dt.StubContext(nil, map[string]interface{}{
		"fortress": guest,
	})

	// wait for the start func to complete
	started := make(chan struct{})
	go func() {
		defer close(started)
		worker, err := manifold.Start(context)
		c.Check(worker, gc.Equals, expectWorker)
		c.Check(err, jc.ErrorIsNil)
	}()
	select {
	case <-started:
	case <-time.After(coretesting.LongWait):
		c.Fatalf("timed out")
	}

	// check the worker's alive
	workertest.CheckAlive(c, expectWorker)

	// check the visit keeps running...
	select {
	case <-time.After(coretesting.ShortWait):
	case <-guest.done:
		c.Fatalf("visit finished early")
	}

	// ...until the worker stops
	expectWorker.Kill()
	select {
	case <-guest.done:
	case <-time.After(coretesting.LongWait):
		c.Fatalf("timed out")
	}
}
开发者ID:makyo,项目名称:juju,代码行数:47,代码来源:housing_test.go


示例8: TestFlagSuccess

func (*HousingSuite) TestFlagSuccess(c *gc.C) {
	expectWorker := &struct{ worker.Worker }{}
	manifold := util.Housing{
		Flags: []string{"flag"},
	}.Decorate(dependency.Manifold{
		Start: func(dependency.Context) (worker.Worker, error) {
			return expectWorker, nil
		},
	})
	context := dt.StubContext(nil, map[string]interface{}{
		"flag": flag{true},
	})

	worker, err := manifold.Start(context)
	c.Check(worker, gc.Equals, expectWorker)
	c.Check(err, jc.ErrorIsNil)
}
开发者ID:makyo,项目名称:juju,代码行数:17,代码来源:housing_test.go


示例9: TestEmptyHousingPopulatedManifold

func (*HousingSuite) TestEmptyHousingPopulatedManifold(c *gc.C) {
	manifold := util.Housing{}.Decorate(dependency.Manifold{
		Inputs: []string{"x", "y", "z"},
		Start:  panicStart,
		Output: panicOutput,
		Filter: panicFilter,
	})

	c.Check(manifold.Inputs, jc.DeepEquals, []string{"x", "y", "z"})
	c.Check(func() {
		manifold.Start(nil)
	}, gc.PanicMatches, "panicStart")
	c.Check(func() {
		manifold.Output(nil, nil)
	}, gc.PanicMatches, "panicOutput")
	c.Check(func() {
		manifold.Filter(nil)
	}, gc.PanicMatches, "panicFilter")
}
开发者ID:makyo,项目名称:juju,代码行数:19,代码来源:housing_test.go



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Golang modelcmd.BootstrapContext函数代码示例发布时间:2022-05-23
下一篇:
Golang engine.Housing类代码示例发布时间: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