github.com/wallyworld/juju@v0.0.0-20161013125918-6cf1bc9d917a/provider/vsphere/environ_policy_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  	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  	c.Check(err, gc.ErrorMatches, "invalid constraint value: arch=ppc64el\nvalid values are:.*")
    61  }
    62  
    63  func (s *environPolSuite) TestSupportNetworks(c *gc.C) {
    64  	isSupported := s.Env.SupportNetworks()
    65  
    66  	c.Check(isSupported, jc.IsFalse)
    67  }