github.com/axw/juju@v0.0.0-20161005053422-4bd6544d08d4/worker/storageprovisioner/manifold_model_test.go (about) 1 // Copyright 2015 Canonical Ltd. 2 // Licensed under the AGPLv3, see LICENCE file for details. 3 4 package storageprovisioner_test 5 6 import ( 7 "github.com/juju/errors" 8 "github.com/juju/testing" 9 jc "github.com/juju/testing/checkers" 10 "github.com/juju/utils/clock" 11 gc "gopkg.in/check.v1" 12 13 "github.com/juju/juju/api/base" 14 "github.com/juju/juju/environs" 15 "github.com/juju/juju/worker/dependency" 16 dt "github.com/juju/juju/worker/dependency/testing" 17 "github.com/juju/juju/worker/storageprovisioner" 18 ) 19 20 type ManifoldSuite struct { 21 testing.IsolationSuite 22 } 23 24 var _ = gc.Suite(&ManifoldSuite{}) 25 26 func (s *ManifoldSuite) TestManifold(c *gc.C) { 27 manifold := storageprovisioner.ModelManifold(storageprovisioner.ModelManifoldConfig{ 28 APICallerName: "grenouille", 29 ClockName: "bustopher", 30 EnvironName: "environ", 31 }) 32 c.Check(manifold.Inputs, jc.DeepEquals, []string{"grenouille", "bustopher", "environ"}) 33 c.Check(manifold.Output, gc.IsNil) 34 c.Check(manifold.Start, gc.NotNil) 35 // ...Start is *not* well-tested, in common with many manifold configs. 36 } 37 38 func (s *ManifoldSuite) TestMissingClock(c *gc.C) { 39 manifold := storageprovisioner.ModelManifold(storageprovisioner.ModelManifoldConfig{ 40 APICallerName: "api-caller", 41 ClockName: "clock", 42 EnvironName: "environ", 43 }) 44 _, err := manifold.Start(dt.StubContext(nil, map[string]interface{}{ 45 "api-caller": struct{ base.APICaller }{}, 46 "clock": dependency.ErrMissing, 47 "environ": struct{ environs.Environ }{}, 48 })) 49 c.Check(errors.Cause(err), gc.Equals, dependency.ErrMissing) 50 } 51 52 func (s *ManifoldSuite) TestMissingAPICaller(c *gc.C) { 53 manifold := storageprovisioner.ModelManifold(storageprovisioner.ModelManifoldConfig{ 54 APICallerName: "api-caller", 55 ClockName: "clock", 56 EnvironName: "environ", 57 }) 58 _, err := manifold.Start(dt.StubContext(nil, map[string]interface{}{ 59 "api-caller": dependency.ErrMissing, 60 "clock": struct{ clock.Clock }{}, 61 "environ": struct{ environs.Environ }{}, 62 })) 63 c.Check(errors.Cause(err), gc.Equals, dependency.ErrMissing) 64 } 65 66 func (s *ManifoldSuite) TestMissingEnviron(c *gc.C) { 67 manifold := storageprovisioner.ModelManifold(storageprovisioner.ModelManifoldConfig{ 68 APICallerName: "api-caller", 69 ClockName: "clock", 70 EnvironName: "environ", 71 }) 72 _, err := manifold.Start(dt.StubContext(nil, map[string]interface{}{ 73 "api-caller": struct{ base.APICaller }{}, 74 "clock": struct{ clock.Clock }{}, 75 "environ": dependency.ErrMissing, 76 })) 77 c.Check(errors.Cause(err), gc.Equals, dependency.ErrMissing) 78 }