github.com/makyo/juju@v0.0.0-20160425123129-2608902037e9/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/worker/dependency" 15 dt "github.com/juju/juju/worker/dependency/testing" 16 "github.com/juju/juju/worker/storageprovisioner" 17 ) 18 19 type ManifoldSuite struct { 20 testing.IsolationSuite 21 } 22 23 var _ = gc.Suite(&ManifoldSuite{}) 24 25 func (s *ManifoldSuite) TestManifold(c *gc.C) { 26 manifold := storageprovisioner.ModelManifold(storageprovisioner.ModelManifoldConfig{ 27 APICallerName: "grenouille", 28 ClockName: "bustopher", 29 }) 30 c.Check(manifold.Inputs, jc.DeepEquals, []string{"grenouille", "bustopher"}) 31 c.Check(manifold.Output, gc.IsNil) 32 c.Check(manifold.Start, gc.NotNil) 33 // ...Start is *not* well-tested, in common with many manifold configs. 34 } 35 36 func (s *ManifoldSuite) TestMissingClock(c *gc.C) { 37 manifold := storageprovisioner.ModelManifold(storageprovisioner.ModelManifoldConfig{ 38 APICallerName: "api-caller", 39 ClockName: "clock", 40 }) 41 _, err := manifold.Start(dt.StubContext(nil, map[string]interface{}{ 42 "api-caller": struct{ base.APICaller }{}, 43 "clock": dependency.ErrMissing, 44 })) 45 c.Check(errors.Cause(err), gc.Equals, dependency.ErrMissing) 46 } 47 48 func (s *ManifoldSuite) TestMissingAPICaller(c *gc.C) { 49 manifold := storageprovisioner.ModelManifold(storageprovisioner.ModelManifoldConfig{ 50 APICallerName: "api-caller", 51 ClockName: "clock", 52 }) 53 _, err := manifold.Start(dt.StubContext(nil, map[string]interface{}{ 54 "api-caller": dependency.ErrMissing, 55 "clock": struct{ clock.Clock }{}, 56 })) 57 c.Check(errors.Cause(err), gc.Equals, dependency.ErrMissing) 58 }