launchpad.net/~rogpeppe/juju-core/500-errgo-fix@v0.0.0-20140213181702-000000002356/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 gc "launchpad.net/gocheck"
     7  
     8  type stateSuite struct {
     9  	uniterSuite
    10  }
    11  
    12  var _ = gc.Suite(&stateSuite{})
    13  
    14  func (s *stateSuite) TestAPIAddresses(c *gc.C) {
    15  	stateAPIAddresses, err := s.State.APIAddresses()
    16  	c.Assert(err, gc.IsNil)
    17  	addresses, err := s.uniter.APIAddresses()
    18  	c.Assert(err, gc.IsNil)
    19  	c.Assert(addresses, gc.DeepEquals, stateAPIAddresses)
    20  	// testing.AddStateServerMachine creates a machine which does *not*
    21  	// match the values in the Environ Config, so these don't match
    22  	apiInfo := s.APIInfo(c)
    23  	c.Assert(addresses, gc.Not(gc.DeepEquals), apiInfo.Addrs)
    24  }
    25  
    26  func (s *stateSuite) TestProviderType(c *gc.C) {
    27  	cfg, err := s.State.EnvironConfig()
    28  	c.Assert(err, gc.IsNil)
    29  
    30  	providerType, err := s.uniter.ProviderType()
    31  	c.Assert(err, gc.IsNil)
    32  	c.Assert(providerType, gc.DeepEquals, cfg.Type())
    33  }
    34  
    35  type noStateServerSuite struct {
    36  	uniterSuite
    37  }
    38  
    39  var _ = gc.Suite(&noStateServerSuite{})
    40  
    41  func (s *noStateServerSuite) SetUpTest(c *gc.C) {
    42  	// avoid adding the state server machine.
    43  	s.setUpTest(c, false)
    44  }
    45  
    46  func (s *noStateServerSuite) TestAPIAddressesFailure(c *gc.C) {
    47  	_, err := s.uniter.APIAddresses()
    48  	c.Assert(err, gc.ErrorMatches, "no state server machines found")
    49  }