github.com/cloudbase/juju-core@v0.0.0-20140504232958-a7271ac7912f/state/api/uniter/state_test.go (about)

     1  // Copyright 2013 Canonical Ltd.
     2  // Licensed under the AGPLv3, see LICENCE file for details.
     3  
     4  package uniter_test
     5  
     6  import (
     7  	gc "launchpad.net/gocheck"
     8  )
     9  
    10  type stateSuite struct {
    11  	uniterSuite
    12  }
    13  
    14  var _ = gc.Suite(&stateSuite{})
    15  
    16  func (s *stateSuite) TestAPIAddresses(c *gc.C) {
    17  	stateAPIAddresses, err := s.State.APIAddresses()
    18  	c.Assert(err, gc.IsNil)
    19  	addresses, err := s.uniter.APIAddresses()
    20  	c.Assert(err, gc.IsNil)
    21  	c.Assert(addresses, gc.DeepEquals, stateAPIAddresses)
    22  	// testing.AddStateServerMachine creates a machine which does *not*
    23  	// match the values in the Environ Config, so these don't match
    24  	apiInfo := s.APIInfo(c)
    25  	c.Assert(addresses, gc.Not(gc.DeepEquals), apiInfo.Addrs)
    26  }
    27  
    28  func (s *stateSuite) TestProviderType(c *gc.C) {
    29  	cfg, err := s.State.EnvironConfig()
    30  	c.Assert(err, gc.IsNil)
    31  
    32  	providerType, err := s.uniter.ProviderType()
    33  	c.Assert(err, gc.IsNil)
    34  	c.Assert(providerType, gc.DeepEquals, cfg.Type())
    35  }
    36  
    37  type noStateServerSuite struct {
    38  	uniterSuite
    39  }
    40  
    41  var _ = gc.Suite(&noStateServerSuite{})
    42  
    43  func (s *noStateServerSuite) SetUpTest(c *gc.C) {
    44  	// avoid adding the state server machine.
    45  	s.setUpTest(c, false)
    46  }
    47  
    48  func (s *noStateServerSuite) TestAPIAddressesFailure(c *gc.C) {
    49  	_, err := s.uniter.APIAddresses()
    50  	c.Assert(err, gc.ErrorMatches, "no state server machines found")
    51  }