示例#1
0
文件: flag_test.go 项目: exekias/juju
func (s *FlagSuite) TestNonEmptyInputs(c *gc.C) {
	base := dependency.Manifold{
		Inputs: []string{"foo", "bar"},
	}
	wrapped := dependency.WithFlag(base, "blib")
	expect := []string{"foo", "bar", "blib"}
	c.Check(wrapped.Inputs, jc.DeepEquals, expect)
}
示例#2
0
文件: flag_test.go 项目: exekias/juju
func (s *FlagSuite) TestStartFalseFlag(c *gc.C) {
	wrapped := dependency.WithFlag(dependency.Manifold{}, "foo")
	getResource := dt.StubGetResource(dt.StubResources{
		"foo": dt.StubResource{Output: stubFlag(false)},
	})
	worker, err := wrapped.Start(getResource)
	c.Check(worker, gc.IsNil)
	c.Check(errors.Cause(err), gc.Equals, dependency.ErrMissing)
}
示例#3
0
文件: flag_test.go 项目: exekias/juju
func (s *FlagSuite) TestStartNotFlag(c *gc.C) {
	wrapped := dependency.WithFlag(dependency.Manifold{}, "foo")
	getResource := dt.StubGetResource(dt.StubResources{
		"foo": dt.StubResource{Output: true},
	})
	worker, err := wrapped.Start(getResource)
	c.Check(worker, gc.IsNil)
	c.Check(err, gc.ErrorMatches, `cannot set true into \*dependency.Flag`)
}
示例#4
0
文件: flag_test.go 项目: exekias/juju
func (s *FlagSuite) TestNonEmptyOutput(c *gc.C) {
	output := func(_ worker.Worker, _ interface{}) error {
		panic("splat")
	}
	base := dependency.Manifold{
		Output: output,
	}
	wrapped := dependency.WithFlag(base, "blah")
	tryOutput := func() {
		wrapped.Output(nil, nil)
	}
	c.Check(tryOutput, gc.PanicMatches, "splat")
}
示例#5
0
文件: flag_test.go 项目: exekias/juju
func (s *FlagSuite) TestStartTrueFlag(c *gc.C) {
	expectWorker := &stubWorker{}
	base := dependency.Manifold{
		Start: func(_ dependency.GetResourceFunc) (worker.Worker, error) {
			return expectWorker, nil
		},
	}
	wrapped := dependency.WithFlag(base, "foo")
	getResource := dt.StubGetResource(dt.StubResources{
		"foo": dt.StubResource{Output: stubFlag(true)},
	})
	worker, err := wrapped.Start(getResource)
	c.Check(worker, gc.Equals, expectWorker)
	c.Check(err, jc.ErrorIsNil)
}
示例#6
0
// ifNotDead wraps a manifold such that it only runs if the responsibility
// flag is set and the model is Alive or Dying.
func ifNotDead(manifold dependency.Manifold) dependency.Manifold {
	return ifResponsible(dependency.WithFlag(manifold, notDeadFlagName))
}
示例#7
0
// ifResponsible wraps a manifold such that it only runs if the
// responsibility flag is set.
func ifResponsible(manifold dependency.Manifold) dependency.Manifold {
	return dependency.WithFlag(manifold, isResponsibleFlagName)
}
示例#8
0
文件: flag_test.go 项目: exekias/juju
func (s *FlagSuite) TestEmptyOutput(c *gc.C) {
	wrapped := dependency.WithFlag(dependency.Manifold{}, "blob")
	c.Check(wrapped.Output, gc.IsNil)
}
示例#9
0
文件: flag_test.go 项目: exekias/juju
func (s *FlagSuite) TestEmptyInputs(c *gc.C) {
	wrapped := dependency.WithFlag(dependency.Manifold{}, "blob")
	c.Check(wrapped.Inputs, jc.DeepEquals, []string{"blob"})
}