github.com/wallyworld/juju@v0.0.0-20161013125918-6cf1bc9d917a/environs/cloudspec_test.go (about) 1 // Copyright 2016 Canonical Ltd. 2 // Licensed under the AGPLv3, see LICENCE file for details. 3 package environs_test 4 5 import ( 6 jc "github.com/juju/testing/checkers" 7 gc "gopkg.in/check.v1" 8 9 "github.com/juju/juju/environs" 10 ) 11 12 type cloudSpecSuite struct { 13 } 14 15 var _ = gc.Suite(&cloudSpecSuite{}) 16 17 func (s *cloudSpecSuite) TestNewRegionSpec(c *gc.C) { 18 tests := []struct { 19 description, cloud, region, errMatch string 20 nilErr bool 21 want *environs.RegionSpec 22 }{ 23 { 24 description: "test empty cloud", 25 cloud: "", 26 region: "aregion", 27 errMatch: "cloud and region are required to be non empty strings", 28 want: nil, 29 }, { 30 description: "test empty region", 31 cloud: "acloud", 32 region: "", 33 errMatch: "cloud and region are required to be non empty strings", 34 want: nil, 35 }, { 36 description: "test valid", 37 cloud: "acloud", 38 region: "aregion", 39 nilErr: true, 40 want: &environs.RegionSpec{Cloud: "acloud", Region: "aregion"}, 41 }, 42 } 43 for i, test := range tests { 44 c.Logf("Test %d: %s", i, test.description) 45 rspec, err := environs.NewRegionSpec(test.cloud, test.region) 46 if !test.nilErr { 47 c.Check(err, gc.ErrorMatches, test.errMatch) 48 } else { 49 c.Check(err, jc.ErrorIsNil) 50 } 51 c.Check(rspec, jc.DeepEquals, test.want) 52 } 53 }