github.com/axw/juju@v0.0.0-20161005053422-4bd6544d08d4/state/controller_test.go (about)

     1  // Copyright 2016 Canonical Ltd.
     2  // Licensed under the AGPLv3, see LICENCE file for details.
     3  
     4  package state_test
     5  
     6  import (
     7  	jc "github.com/juju/testing/checkers"
     8  	gc "gopkg.in/check.v1"
     9  
    10  	"github.com/juju/juju/controller"
    11  	"github.com/juju/juju/state"
    12  )
    13  
    14  type ControllerConfigSuite struct {
    15  	ConnSuite
    16  }
    17  
    18  var _ = gc.Suite(&ControllerConfigSuite{})
    19  
    20  func (s *ControllerConfigSuite) TestControllerAndModelConfigInitialisation(c *gc.C) {
    21  	// Test setup has created model using a fully populated environs.Config.
    22  	// This test ensure that the controller specific attributes have been separated out.
    23  	controllerSettings, err := s.State.ReadSettings(state.ControllersC, "controllerSettings")
    24  	c.Assert(err, jc.ErrorIsNil)
    25  
    26  	optional := map[string]bool{
    27  		controller.IdentityURL:        true,
    28  		controller.IdentityPublicKey:  true,
    29  		controller.AutocertURLKey:     true,
    30  		controller.AutocertDNSNameKey: true,
    31  	}
    32  	for _, controllerAttr := range controller.ControllerOnlyConfigAttributes {
    33  		v, ok := controllerSettings.Get(controllerAttr)
    34  		if !optional[controllerAttr] {
    35  			c.Assert(ok, jc.IsTrue)
    36  			c.Assert(v, gc.Not(gc.Equals), "")
    37  		}
    38  	}
    39  }
    40  
    41  func (s *ControllerConfigSuite) TestControllerConfig(c *gc.C) {
    42  	cfg, err := s.State.ControllerConfig()
    43  	c.Assert(err, jc.ErrorIsNil)
    44  	m, err := s.State.ControllerModel()
    45  	c.Assert(err, jc.ErrorIsNil)
    46  	c.Assert(cfg["controller-uuid"], gc.Equals, m.ControllerUUID())
    47  }