github.com/juju/juju@v0.0.0-20240327075706-a90865de2538/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/clock" 8 "github.com/juju/errors" 9 "github.com/juju/testing" 10 jc "github.com/juju/testing/checkers" 11 "github.com/juju/worker/v3/dependency" 12 dt "github.com/juju/worker/v3/dependency/testing" 13 gc "gopkg.in/check.v1" 14 15 "github.com/juju/juju/api/base" 16 "github.com/juju/juju/environs" 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 StorageRegistryName: "environ", 30 }) 31 c.Check(manifold.Inputs, jc.DeepEquals, []string{"grenouille", "environ"}) 32 c.Check(manifold.Output, gc.IsNil) 33 c.Check(manifold.Start, gc.NotNil) 34 // ...Start is *not* well-tested, in common with many manifold configs. 35 } 36 37 func (s *ManifoldSuite) TestMissingAPICaller(c *gc.C) { 38 manifold := storageprovisioner.ModelManifold(storageprovisioner.ModelManifoldConfig{ 39 APICallerName: "api-caller", 40 StorageRegistryName: "environ", 41 }) 42 _, err := manifold.Start(dt.StubContext(nil, map[string]interface{}{ 43 "api-caller": dependency.ErrMissing, 44 "clock": struct{ clock.Clock }{}, 45 "environ": struct{ environs.Environ }{}, 46 })) 47 c.Check(errors.Cause(err), gc.Equals, dependency.ErrMissing) 48 } 49 50 func (s *ManifoldSuite) TestMissingEnviron(c *gc.C) { 51 manifold := storageprovisioner.ModelManifold(storageprovisioner.ModelManifoldConfig{ 52 APICallerName: "api-caller", 53 StorageRegistryName: "environ", 54 }) 55 _, err := manifold.Start(dt.StubContext(nil, map[string]interface{}{ 56 "api-caller": struct{ base.APICaller }{}, 57 "clock": struct{ clock.Clock }{}, 58 "environ": dependency.ErrMissing, 59 })) 60 c.Check(errors.Cause(err), gc.Equals, dependency.ErrMissing) 61 }