github.com/mattyw/juju@v0.0.0-20140610034352-732aecd63861/provider/azure/environprovider_test.go (about) 1 // Copyright 2013 Canonical Ltd. 2 // Licensed under the AGPLv3, see LICENCE file for details. 3 4 package azure 5 6 import ( 7 gc "launchpad.net/gocheck" 8 9 "github.com/juju/juju/environs/config" 10 ) 11 12 type environProviderSuite struct { 13 providerSuite 14 } 15 16 var _ = gc.Suite(&environProviderSuite{}) 17 18 func (*environProviderSuite) TestOpen(c *gc.C) { 19 prov := azureEnvironProvider{} 20 attrs := makeAzureConfigMap(c) 21 attrs["name"] = "my-shiny-new-env" 22 cfg, err := config.New(config.NoDefaults, attrs) 23 c.Assert(err, gc.IsNil) 24 25 env, err := prov.Open(cfg) 26 c.Assert(err, gc.IsNil) 27 28 c.Check(env.Name(), gc.Equals, attrs["name"]) 29 } 30 31 func (environProviderSuite) TestOpenReturnsNilInterfaceUponFailure(c *gc.C) { 32 prov := azureEnvironProvider{} 33 attrs := makeAzureConfigMap(c) 34 // Make the config invalid. 35 attrs["location"] = "" 36 cfg, err := config.New(config.NoDefaults, attrs) 37 c.Assert(err, gc.IsNil) 38 39 env, err := prov.Open(cfg) 40 // When Open() fails (i.e. returns a non-nil error), it returns an 41 // environs.Environ interface object with a nil value and a nil 42 // type. 43 c.Check(env, gc.Equals, nil) 44 c.Check(err, gc.ErrorMatches, ".*environment has no location; you need to set one.*") 45 }