~nskaggs/+junk/xenial-test

« back to all changes in this revision

Viewing changes to src/github.com/juju/juju/provider/vsphere/environ_test.go

  • Committer: Nicholas Skaggs
  • Date: 2016-10-24 20:56:05 UTC
  • Revision ID: nicholas.skaggs@canonical.com-20161024205605-z8lta0uvuhtxwzwl
Initi with beta15

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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
}