本文整理汇总了Golang中github.com/juju/juju/worker/dependency.SelfManifold函数的典型用法代码示例。如果您正苦于以下问题:Golang SelfManifold函数的具体用法?Golang SelfManifold怎么用?Golang SelfManifold使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了SelfManifold函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: TestOutputReporter
func (s *SelfSuite) TestOutputReporter(c *gc.C) {
manifold := dependency.SelfManifold(s.engine)
var reporter dependency.Reporter
err := manifold.Output(s.engine, &reporter)
c.Check(err, jc.ErrorIsNil)
c.Check(reporter, gc.Equals, s.engine)
}
示例2: TestActuallyWorks
func (s *SelfSuite) TestActuallyWorks(c *gc.C) {
// Create and install a manifold with an unsatisfied dependency.
mh1 := newManifoldHarness("self")
err := s.engine.Install("dependent", mh1.Manifold())
c.Assert(err, jc.ErrorIsNil)
mh1.AssertNoStart(c)
// Install an engine inside itself; once it's "started", dependent will
// be restarted.
manifold := dependency.SelfManifold(s.engine)
err = s.engine.Install("self", manifold)
c.Assert(err, jc.ErrorIsNil)
mh1.AssertOneStart(c)
// Check we can still stop it (with a timeout -- injudicious
// implementation changes could induce deadlocks).
done := make(chan struct{})
go func() {
err := worker.Stop(s.engine)
c.Check(err, jc.ErrorIsNil)
close(done)
}()
select {
case <-done:
case <-time.After(coretesting.LongWait):
c.Fatalf("timed out")
}
}
示例3: TestOutputInstaller
func (s *SelfSuite) TestOutputInstaller(c *gc.C) {
manifold := dependency.SelfManifold(s.engine)
var installer dependency.Installer
err := manifold.Output(s.engine, &installer)
c.Check(err, jc.ErrorIsNil)
c.Check(installer, gc.Equals, s.engine)
}
示例4: TestOutputBadOutput
func (s *SelfSuite) TestOutputBadOutput(c *gc.C) {
manifold := dependency.SelfManifold(s.engine)
var unknown interface{}
err := manifold.Output(s.engine, &unknown)
c.Check(err, gc.ErrorMatches, "out should be a \\*Installer or a \\*Reporter; is .*")
c.Check(unknown, gc.IsNil)
}
示例5: TestOutputBadInput
func (s *SelfSuite) TestOutputBadInput(c *gc.C) {
s.fix.run(c, func(engine dependency.Engine) {
manifold := dependency.SelfManifold(engine)
var input dependency.Engine
err := manifold.Output(input, nil)
c.Check(err, gc.ErrorMatches, "unexpected input worker")
})
}
示例6: TestStart
func (s *SelfSuite) TestStart(c *gc.C) {
s.fix.run(c, func(engine dependency.Engine) {
manifold := dependency.SelfManifold(engine)
actual, err := manifold.Start(nil)
c.Check(err, jc.ErrorIsNil)
c.Check(actual, gc.Equals, engine)
})
}
示例7: TestOutputInstaller
func (s *SelfSuite) TestOutputInstaller(c *gc.C) {
s.fix.run(c, func(engine dependency.Engine) {
manifold := dependency.SelfManifold(engine)
var installer dependency.Installer
err := manifold.Output(engine, &installer)
c.Check(err, jc.ErrorIsNil)
c.Check(installer, gc.Equals, engine)
})
}
示例8: TestOutputReporter
func (s *SelfSuite) TestOutputReporter(c *gc.C) {
s.fix.run(c, func(engine *dependency.Engine) {
manifold := dependency.SelfManifold(engine)
var reporter dependency.Reporter
err := manifold.Output(engine, &reporter)
c.Check(err, jc.ErrorIsNil)
c.Check(reporter, gc.Equals, engine)
})
}
示例9: TestStress
func (s *SelfSuite) TestStress(c *gc.C) {
s.fix.run(c, func(engine dependency.Engine) {
// Repeatedly install a manifold inside itself.
manifold := dependency.SelfManifold(engine)
for i := 0; i < 100; i++ {
go engine.Install(fmt.Sprintf("self-%d", i), manifold)
}
// Give it a moment to screw up if it's going to
// (injudicious implementation could induce deadlock)
// then let the fixture worry about a clean kill.
workertest.CheckAlive(c, engine)
})
}
示例10: TestActuallyWorks
func (s *SelfSuite) TestActuallyWorks(c *gc.C) {
// Install an engine inside itself.
manifold := dependency.SelfManifold(s.engine)
err := s.engine.Install("self", manifold)
c.Assert(err, jc.ErrorIsNil)
// Check we can still stop it (with a timeout -- injudicious
// implementation changes could induce deadlocks).
done := make(chan struct{})
go func() {
err := worker.Stop(s.engine)
c.Check(err, jc.ErrorIsNil)
close(done)
}()
select {
case <-done:
case <-time.After(coretesting.LongWait):
c.Fatalf("timed out")
}
}
示例11: TestStress
func (s *SelfSuite) TestStress(c *gc.C) {
// Repeatedly install a manifold inside itself.
manifold := dependency.SelfManifold(s.engine)
for i := 0; i < 100; i++ {
go s.engine.Install(fmt.Sprintf("self-%d", i), manifold)
}
// Check we can still stop it (with a timeout -- injudicious
// implementation changes could induce deadlocks).
done := make(chan struct{})
go func() {
err := worker.Stop(s.engine)
c.Check(err, jc.ErrorIsNil)
close(done)
}()
select {
case <-done:
case <-time.After(coretesting.LongWait):
c.Fatalf("timed out")
}
}
示例12: TestActuallyWorks
func (s *SelfSuite) TestActuallyWorks(c *gc.C) {
s.fix.run(c, func(engine dependency.Engine) {
// Create and install a manifold with an unsatisfied dependency.
mh1 := newManifoldHarness("self")
err := engine.Install("dependent", mh1.Manifold())
c.Assert(err, jc.ErrorIsNil)
mh1.AssertNoStart(c)
// Install an engine inside itself; once it's "started", dependent will
// be restarted.
manifold := dependency.SelfManifold(engine)
err = engine.Install("self", manifold)
c.Assert(err, jc.ErrorIsNil)
mh1.AssertOneStart(c)
// Give it a moment to screw up if it's going to
// (injudicious implementation could induce deadlock)
// then let the fixture worry about a clean kill.
workertest.CheckAlive(c, engine)
})
}
示例13: TestStart
func (s *SelfSuite) TestStart(c *gc.C) {
manifold := dependency.SelfManifold(s.engine)
engine, err := manifold.Start(nil)
c.Check(err, jc.ErrorIsNil)
c.Check(engine, gc.Equals, s.engine)
}
示例14: TestInputs
func (s *SelfSuite) TestInputs(c *gc.C) {
manifold := dependency.SelfManifold(s.engine)
c.Check(manifold.Inputs, gc.HasLen, 0)
}
示例15: TestInputs
func (s *SelfSuite) TestInputs(c *gc.C) {
s.fix.run(c, func(engine dependency.Engine) {
manifold := dependency.SelfManifold(engine)
c.Check(manifold.Inputs, gc.HasLen, 0)
})
}