github.com/wallyworld/juju@v0.0.0-20161013125918-6cf1bc9d917a/provider/vsphere/environ_test.go (about) 1 // Copyright 2015 Canonical Ltd. 2 // Licensed under the AGPLv3, see LICENCE file for details. 3 4 // +build !gccgo 5 6 package vsphere_test 7 8 import ( 9 "os" 10 11 "github.com/juju/errors" 12 jc "github.com/juju/testing/checkers" 13 gc "gopkg.in/check.v1" 14 15 "github.com/juju/juju/environs" 16 envtesting "github.com/juju/juju/environs/testing" 17 "github.com/juju/juju/feature" 18 "github.com/juju/juju/juju/osenv" 19 "github.com/juju/juju/provider/vsphere" 20 "github.com/juju/juju/testing" 21 ) 22 23 type environSuite struct { 24 vsphere.BaseSuite 25 } 26 27 var _ = gc.Suite(&environSuite{}) 28 29 func (s *environSuite) SetUpTest(c *gc.C) { 30 s.BaseSuite.SetUpTest(c) 31 } 32 33 func (s *environSuite) TestBootstrap(c *gc.C) { 34 s.PatchValue(&vsphere.Bootstrap, func(ctx environs.BootstrapContext, env environs.Environ, args environs.BootstrapParams, 35 ) (*environs.BootstrapResult, error) { 36 return nil, errors.New("Bootstrap called") 37 }) 38 39 os.Setenv(osenv.JujuFeatureFlagEnvKey, feature.VSphereProvider) 40 _, err := s.Env.Bootstrap(nil, environs.BootstrapParams{ControllerConfig: testing.FakeControllerConfig()}) 41 c.Assert(err, gc.ErrorMatches, "Bootstrap called") 42 } 43 44 func (s *environSuite) TestDestroy(c *gc.C) { 45 s.PatchValue(&vsphere.DestroyEnv, func(env environs.Environ) error { 46 return errors.New("Destroy called") 47 }) 48 err := s.Env.Destroy() 49 c.Assert(err, gc.ErrorMatches, "Destroy called") 50 } 51 52 func (s *environSuite) TestPrepareForBootstrap(c *gc.C) { 53 err := s.Env.PrepareForBootstrap(envtesting.BootstrapContext(c)) 54 c.Check(err, jc.ErrorIsNil) 55 } 56 57 func (s *environSuite) TestSupportsNetworking(c *gc.C) { 58 var _ environs.Networking = s.Env 59 _, ok := environs.SupportsNetworking(s.Env) 60 c.Assert(ok, jc.IsTrue) 61 }