github.com/axw/juju@v0.0.0-20161005053422-4bd6544d08d4/provider/manual/config_test.go (about)

     1  // Copyright 2013 Canonical Ltd.
     2  // Licensed under the AGPLv3, see LICENCE file for details.
     3  
     4  package manual
     5  
     6  import (
     7  	jc "github.com/juju/testing/checkers"
     8  	gc "gopkg.in/check.v1"
     9  
    10  	"github.com/juju/juju/environs"
    11  	"github.com/juju/juju/environs/config"
    12  	coretesting "github.com/juju/juju/testing"
    13  )
    14  
    15  type configSuite struct {
    16  	coretesting.FakeJujuXDGDataHomeSuite
    17  }
    18  
    19  var _ = gc.Suite(&configSuite{})
    20  
    21  func CloudSpec() environs.CloudSpec {
    22  	return environs.CloudSpec{
    23  		Name:     "manual",
    24  		Type:     "manual",
    25  		Endpoint: "hostname",
    26  	}
    27  }
    28  
    29  func MinimalConfigValues() map[string]interface{} {
    30  	return map[string]interface{}{
    31  		"name":            "test",
    32  		"type":            "manual",
    33  		"uuid":            coretesting.ModelTag.Id(),
    34  		"controller-uuid": coretesting.ControllerTag.Id(),
    35  		"firewall-mode":   "instance",
    36  		// While the ca-cert bits aren't entirely minimal, they avoid the need
    37  		// to set up a fake home.
    38  		"ca-cert":        coretesting.CACert,
    39  		"ca-private-key": coretesting.CAKey,
    40  	}
    41  }
    42  
    43  func MinimalConfig(c *gc.C) *config.Config {
    44  	minimal := MinimalConfigValues()
    45  	testConfig, err := config.New(config.UseDefaults, minimal)
    46  	c.Assert(err, jc.ErrorIsNil)
    47  	return testConfig
    48  }
    49  
    50  func getModelConfig(c *gc.C, attrs map[string]interface{}) *environConfig {
    51  	testConfig, err := config.New(config.UseDefaults, attrs)
    52  	c.Assert(err, jc.ErrorIsNil)
    53  	envConfig, err := manualProvider{}.validate(testConfig, nil)
    54  	c.Assert(err, jc.ErrorIsNil)
    55  	return envConfig
    56  }