github.com/makyo/juju@v0.0.0-20160425123129-2608902037e9/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  	gc "gopkg.in/check.v1"
    13  
    14  	"github.com/juju/juju/environs"
    15  	"github.com/juju/juju/feature"
    16  	"github.com/juju/juju/juju/osenv"
    17  	"github.com/juju/juju/provider/vsphere"
    18  )
    19  
    20  type environSuite struct {
    21  	vsphere.BaseSuite
    22  }
    23  
    24  var _ = gc.Suite(&environSuite{})
    25  
    26  func (s *environSuite) SetUpTest(c *gc.C) {
    27  	s.BaseSuite.SetUpTest(c)
    28  }
    29  
    30  func (s *environSuite) TestBootstrap(c *gc.C) {
    31  	s.PatchValue(&vsphere.Bootstrap, func(ctx environs.BootstrapContext, env environs.Environ, args environs.BootstrapParams,
    32  	) (*environs.BootstrapResult, error) {
    33  		return nil, errors.New("Bootstrap called")
    34  	})
    35  
    36  	os.Setenv(osenv.JujuFeatureFlagEnvKey, feature.VSphereProvider)
    37  	_, err := s.Env.Bootstrap(nil, environs.BootstrapParams{})
    38  	c.Assert(err, gc.ErrorMatches, "Bootstrap called")
    39  }
    40  
    41  func (s *environSuite) TestDestroy(c *gc.C) {
    42  	s.PatchValue(&vsphere.DestroyEnv, func(env environs.Environ) error {
    43  		return errors.New("Destroy called")
    44  	})
    45  	err := s.Env.Destroy()
    46  	c.Assert(err, gc.ErrorMatches, "Destroy called")
    47  }