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

Golang workertest.NewErrorWorker函数代码示例

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

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



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

示例1: TestStopKills

func (*WorkerSuite) TestStopKills(c *gc.C) {
	w := workertest.NewErrorWorker(nil)
	defer workertest.CleanKill(c, w)

	worker.Stop(w)
	workertest.CheckKilled(c, w)
}
开发者ID:bac,项目名称:juju,代码行数:7,代码来源:worker_test.go


示例2: TestStartSuccess

func (*OccupySuite) TestStartSuccess(c *gc.C) {
	fix := newFixture(c)
	defer fix.TearDown(c)
	c.Check(fix.Guard(c).Unlock(), jc.ErrorIsNil)

	// Start a worker...
	expect := workertest.NewErrorWorker(nil)
	defer workertest.CleanKill(c, expect)
	run := func() (worker.Worker, error) {
		return expect, nil
	}
	worker, err := fortress.Occupy(fix.Guest(c), run, nil)
	c.Assert(err, jc.ErrorIsNil)
	c.Check(worker, gc.Equals, expect)

	// ...and check we can't lockdown again...
	locked := make(chan error, 1)
	go func() {
		locked <- fix.Guard(c).Lockdown(nil)
	}()
	select {
	case err := <-locked:
		c.Fatalf("unexpected Lockdown result: %v", err)
	case <-time.After(coretesting.ShortWait):
	}

	// ...until the worker completes.
	workertest.CleanKill(c, worker)
	select {
	case err := <-locked:
		c.Check(err, jc.ErrorIsNil)
	case <-time.After(coretesting.LongWait):
		c.Fatalf("visit never completed")
	}
}
开发者ID:bac,项目名称:juju,代码行数:35,代码来源:occupy_test.go


示例3: newMockBackend

func newMockBackend() *mockBackend {
	return &mockBackend{
		envWatcher: &mockEnvWatcher{
			Worker:  workertest.NewErrorWorker(nil),
			changes: make(chan []string),
		},
	}
}
开发者ID:AlexisBruemmer,项目名称:juju,代码行数:8,代码来源:modelworkermanager_test.go


示例4: TestCheckKilledTimeout

func (s *Suite) TestCheckKilledTimeout(c *gc.C) {
	w := workertest.NewErrorWorker(nil)
	defer workertest.CleanKill(c, w)

	err := workertest.CheckKilled(c, w)
	s.CheckFailed(c)
	c.Check(err, gc.ErrorMatches, "workertest: worker not stopping")
}
开发者ID:exekias,项目名称:juju,代码行数:8,代码来源:workertest_test.go


示例5: TestCheckKillSuccess

func (s *Suite) TestCheckKillSuccess(c *gc.C) {
	expect := errors.New("fledbon")
	w := workertest.NewErrorWorker(expect)
	defer workertest.DirtyKill(c, w)

	err := workertest.CheckKill(c, w)
	c.Check(err, gc.Equals, expect)
}
开发者ID:exekias,项目名称:juju,代码行数:8,代码来源:workertest_test.go


示例6: NewFakeNotifyWatcher

func NewFakeNotifyWatcher() *FakeNotifyWatcher {
	ch := make(chan struct{}, 1)
	ch <- struct{}{}
	return &FakeNotifyWatcher{
		Worker: workertest.NewErrorWorker(nil),
		C:      ch,
	}
}
开发者ID:bac,项目名称:juju,代码行数:8,代码来源:fakenotifywatcher.go


示例7: TestCheckKilledSuccess

func (s *Suite) TestCheckKilledSuccess(c *gc.C) {
	expect := errors.New("snifplog")
	w := workertest.NewErrorWorker(expect)
	defer workertest.DirtyKill(c, w)

	w.Kill()
	err := workertest.CheckKilled(c, w)
	c.Check(err, gc.Equals, expect)
}
开发者ID:exekias,项目名称:juju,代码行数:9,代码来源:workertest_test.go


示例8: newStubWatcher

func newStubWatcher() *stubWatcher {
	changes := make(chan []string, 3)
	changes <- []string{"expected", "first"}
	changes <- []string{"expected", "second"}
	changes <- []string{"unexpected?"}
	return &stubWatcher{
		Worker:  workertest.NewErrorWorker(nil),
		changes: changes,
	}
}
开发者ID:AlexisBruemmer,项目名称:juju,代码行数:10,代码来源:fixture_test.go


示例9: newStubWatcher

func newStubWatcher() *stubWatcher {
	changes := make(chan struct{}, 3)
	changes <- struct{}{}
	changes <- struct{}{}
	changes <- struct{}{}
	return &stubWatcher{
		Worker:     workertest.NewErrorWorker(nil),
		notifyChan: changes,
	}
}
开发者ID:bac,项目名称:juju,代码行数:10,代码来源:fixture_test.go


示例10: newMockWatcher

// newMockWatcher returns a watcher.NotifyWatcher that always
// sends 3 changes and then sits quietly until killed.
func newMockWatcher() *mockWatcher {
	const count = 3
	changes := make(chan struct{}, count)
	for i := 0; i < count; i++ {
		changes <- struct{}{}
	}
	return &mockWatcher{
		Worker:  workertest.NewErrorWorker(nil),
		changes: changes,
	}
}
开发者ID:makyo,项目名称:juju,代码行数:13,代码来源:util_test.go


示例11: startPinger

func (context *context) startPinger() (presence.Pinger, error) {
	context.stub.AddCall("Start")
	context.checkCleanedUp()
	if startErr := context.stub.NextErr(); startErr != nil {
		return nil, startErr
	}

	context.mu.Lock()
	defer context.mu.Unlock()
	pingerErr := context.stub.NextErr()
	context.current = workertest.NewErrorWorker(pingerErr)
	context.starts <- context.current
	return mockPinger{context.current}, nil
}
开发者ID:bac,项目名称:juju,代码行数:14,代码来源:util_test.go


示例12: WatchModelResources

func (mock *mockFacade) WatchModelResources() (watcher.NotifyWatcher, error) {
	mock.stub.AddCall("WatchModelResources")
	if err := mock.stub.NextErr(); err != nil {
		return nil, err
	}
	const count = 5
	changes := make(chan struct{}, count)
	for i := 0; i < count; i++ {
		changes <- struct{}{}
	}
	return &mockWatcher{
		Worker:  workertest.NewErrorWorker(nil),
		changes: changes,
	}, nil
}
开发者ID:AlexisBruemmer,项目名称:juju,代码行数:15,代码来源:mock_test.go


示例13: newWorkerList

// newWorkerList converts the supplied errors into a list of workers to
// be returned in order from the result's Next func (at which point they
// are sent on the reports chan as well).
func newWorkerList(errs []error) *workerList {
	count := len(errs)
	reports := make(chan worker.Worker, count)
	workers := make([]worker.Worker, count)
	for i, err := range errs {
		if err == ErrFailStart {
			workers[i] = nil
		} else {
			workers[i] = workertest.NewErrorWorker(err)
		}
	}
	return &workerList{
		workers: workers,
		reports: reports,
	}
}
开发者ID:kat-co,项目名称:juju,代码行数:19,代码来源:fixture_test.go


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


示例15: TestDeadWaits

func (*WorkerSuite) TestDeadWaits(c *gc.C) {
	w := workertest.NewErrorWorker(nil)
	defer workertest.CleanKill(c, w)

	dead := worker.Dead(w)
	select {
	case <-time.After(coretesting.ShortWait):
	case _, ok := <-dead:
		if !ok {
			c.Fatalf("Dead closed early")
		} else {
			c.Fatalf("Dead sent unexpectedly")
		}
	}

	w.Kill()
	select {
	case _, ok := <-dead:
		c.Check(ok, jc.IsFalse)
	case <-time.After(coretesting.LongWait):
		c.Fatalf("Dead never closed")
	}
}
开发者ID:bac,项目名称:juju,代码行数:23,代码来源:worker_test.go


示例16: newMockWatcher

func newMockWatcher(changes chan struct{}) *mockWatcher {
	return &mockWatcher{
		Worker:  workertest.NewErrorWorker(nil),
		changes: changes,
	}
}
开发者ID:bac,项目名称:juju,代码行数:6,代码来源:util_test.go


示例17: TestCleanKillFailure

func (s *Suite) TestCleanKillFailure(c *gc.C) {
	w := workertest.NewErrorWorker(errors.New("kebdrix"))

	workertest.CleanKill(c, w)
	s.CheckFailed(c)
}
开发者ID:exekias,项目名称:juju,代码行数:6,代码来源:workertest_test.go


示例18: TestCleanKillSuccess

func (s *Suite) TestCleanKillSuccess(c *gc.C) {
	w := workertest.NewErrorWorker(nil)

	workertest.CleanKill(c, w)
}
开发者ID:exekias,项目名称:juju,代码行数:5,代码来源:workertest_test.go


示例19: newStubWatcher

func newStubWatcher() *stubWatcher {
	return &stubWatcher{
		Worker:  workertest.NewErrorWorker(nil),
		changes: make(chan watcher.MigrationStatus, 1),
	}
}
开发者ID:makyo,项目名称:juju,代码行数:6,代码来源:worker_test.go


示例20: TestCheckAliveSuccess

func (s *Suite) TestCheckAliveSuccess(c *gc.C) {
	w := workertest.NewErrorWorker(nil)
	defer workertest.CleanKill(c, w)

	workertest.CheckAlive(c, w)
}
开发者ID:exekias,项目名称:juju,代码行数:6,代码来源:workertest_test.go



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Golang wrench.IsActive函数代码示例发布时间:2022-05-23
下一篇:
Golang workertest.DirtyKill函数代码示例发布时间: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