github.com/makyo/juju@v0.0.0-20160425123129-2608902037e9/provider/gce/google/config_connection_test.go (about)

     1  // Copyright 2015 Canonical Ltd.
     2  // Licensed under the AGPLv3, see LICENCE file for details.
     3  
     4  package google_test
     5  
     6  import (
     7  	jc "github.com/juju/testing/checkers"
     8  	gc "gopkg.in/check.v1"
     9  
    10  	"github.com/juju/juju/provider/gce/google"
    11  )
    12  
    13  type connConfigSuite struct {
    14  	google.BaseSuite
    15  }
    16  
    17  var _ = gc.Suite(&connConfigSuite{})
    18  
    19  func (*connConfigSuite) TestValidateValid(c *gc.C) {
    20  	cfg := google.ConnectionConfig{
    21  		Region:    "spam",
    22  		ProjectID: "eggs",
    23  	}
    24  	err := cfg.Validate()
    25  
    26  	c.Check(err, jc.ErrorIsNil)
    27  }
    28  
    29  func (*connConfigSuite) TestValidateMissingRegion(c *gc.C) {
    30  	cfg := google.ConnectionConfig{
    31  		ProjectID: "eggs",
    32  	}
    33  	err := cfg.Validate()
    34  
    35  	c.Assert(err, gc.FitsTypeOf, &google.InvalidConfigValue{})
    36  	c.Check(err.(*google.InvalidConfigValue).Key, gc.Equals, "GCE_REGION")
    37  }
    38  
    39  func (*connConfigSuite) TestValidateMissingProjectID(c *gc.C) {
    40  	cfg := google.ConnectionConfig{
    41  		Region: "spam",
    42  	}
    43  	err := cfg.Validate()
    44  
    45  	c.Assert(err, gc.FitsTypeOf, &google.InvalidConfigValue{})
    46  	c.Check(err.(*google.InvalidConfigValue).Key, gc.Equals, "GCE_PROJECT_ID")
    47  }