1
// Copyright 2015 Canonical Ltd.
2
// Licensed under the AGPLv3, see LICENCE file for details.
9
jc "github.com/juju/testing/checkers"
10
gc "gopkg.in/check.v1"
12
"github.com/juju/juju/constraints"
13
"github.com/juju/juju/provider/vsphere"
16
type environPolSuite struct {
20
var _ = gc.Suite(&environPolSuite{})
22
func (s *environPolSuite) TestConstraintsValidator(c *gc.C) {
23
validator, err := s.Env.ConstraintsValidator()
24
c.Assert(err, jc.ErrorIsNil)
26
cons := constraints.MustParse("arch=amd64")
27
unsupported, err := validator.Validate(cons)
28
c.Assert(err, jc.ErrorIsNil)
30
c.Check(unsupported, gc.HasLen, 0)
33
func (s *environPolSuite) TestConstraintsValidatorEmpty(c *gc.C) {
34
validator, err := s.Env.ConstraintsValidator()
35
c.Assert(err, jc.ErrorIsNil)
37
unsupported, err := validator.Validate(constraints.Value{})
38
c.Assert(err, jc.ErrorIsNil)
40
c.Check(unsupported, gc.HasLen, 0)
43
func (s *environPolSuite) TestConstraintsValidatorUnsupported(c *gc.C) {
44
validator, err := s.Env.ConstraintsValidator()
45
c.Assert(err, jc.ErrorIsNil)
47
cons := constraints.MustParse("arch=amd64 tags=foo virt-type=kvm")
48
unsupported, err := validator.Validate(cons)
49
c.Assert(err, jc.ErrorIsNil)
51
c.Check(unsupported, jc.SameContents, []string{"tags", "virt-type"})
54
func (s *environPolSuite) TestConstraintsValidatorVocabArch(c *gc.C) {
55
validator, err := s.Env.ConstraintsValidator()
56
c.Assert(err, jc.ErrorIsNil)
58
cons := constraints.MustParse("arch=ppc64el")
59
_, err = validator.Validate(cons)
61
c.Check(err, gc.ErrorMatches, "invalid constraint value: arch=ppc64el\nvalid values are:.*")
64
func (s *environPolSuite) TestSupportNetworks(c *gc.C) {
65
isSupported := s.Env.SupportNetworks()
67
c.Check(isSupported, jc.IsFalse)