~nskaggs/+junk/xenial-test

« back to all changes in this revision

Viewing changes to src/github.com/juju/juju/provider/vsphere/environ_policy_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
        jc "github.com/juju/testing/checkers"
 
10
        gc "gopkg.in/check.v1"
 
11
 
 
12
        "github.com/juju/juju/constraints"
 
13
        "github.com/juju/juju/provider/vsphere"
 
14
)
 
15
 
 
16
type environPolSuite struct {
 
17
        vsphere.BaseSuite
 
18
}
 
19
 
 
20
var _ = gc.Suite(&environPolSuite{})
 
21
 
 
22
func (s *environPolSuite) TestConstraintsValidator(c *gc.C) {
 
23
        validator, err := s.Env.ConstraintsValidator()
 
24
        c.Assert(err, jc.ErrorIsNil)
 
25
 
 
26
        cons := constraints.MustParse("arch=amd64")
 
27
        unsupported, err := validator.Validate(cons)
 
28
        c.Assert(err, jc.ErrorIsNil)
 
29
 
 
30
        c.Check(unsupported, gc.HasLen, 0)
 
31
}
 
32
 
 
33
func (s *environPolSuite) TestConstraintsValidatorEmpty(c *gc.C) {
 
34
        validator, err := s.Env.ConstraintsValidator()
 
35
        c.Assert(err, jc.ErrorIsNil)
 
36
 
 
37
        unsupported, err := validator.Validate(constraints.Value{})
 
38
        c.Assert(err, jc.ErrorIsNil)
 
39
 
 
40
        c.Check(unsupported, gc.HasLen, 0)
 
41
}
 
42
 
 
43
func (s *environPolSuite) TestConstraintsValidatorUnsupported(c *gc.C) {
 
44
        validator, err := s.Env.ConstraintsValidator()
 
45
        c.Assert(err, jc.ErrorIsNil)
 
46
 
 
47
        cons := constraints.MustParse("arch=amd64 tags=foo virt-type=kvm")
 
48
        unsupported, err := validator.Validate(cons)
 
49
        c.Assert(err, jc.ErrorIsNil)
 
50
 
 
51
        c.Check(unsupported, jc.SameContents, []string{"tags", "virt-type"})
 
52
}
 
53
 
 
54
func (s *environPolSuite) TestConstraintsValidatorVocabArch(c *gc.C) {
 
55
        validator, err := s.Env.ConstraintsValidator()
 
56
        c.Assert(err, jc.ErrorIsNil)
 
57
 
 
58
        cons := constraints.MustParse("arch=ppc64el")
 
59
        _, err = validator.Validate(cons)
 
60
 
 
61
        c.Check(err, gc.ErrorMatches, "invalid constraint value: arch=ppc64el\nvalid values are:.*")
 
62
}
 
63
 
 
64
func (s *environPolSuite) TestSupportNetworks(c *gc.C) {
 
65
        isSupported := s.Env.SupportNetworks()
 
66
 
 
67
        c.Check(isSupported, jc.IsFalse)
 
68
}