github.com/altoros/juju-vmware@v0.0.0-20150312064031-f19ae857ccca/upgrades/rsyslogport_test.go (about)

     1  // Copyright 2014 Canonical Ltd.
     2  // Licensed under the AGPLv3, see LICENCE file for details.
     3  
     4  package upgrades_test
     5  
     6  import (
     7  	jc "github.com/juju/testing/checkers"
     8  	gc "gopkg.in/check.v1"
     9  
    10  	"github.com/juju/juju/environs/config"
    11  	jujutesting "github.com/juju/juju/juju/testing"
    12  	"github.com/juju/juju/state"
    13  	"github.com/juju/juju/upgrades"
    14  )
    15  
    16  type rsyslogPortSuite struct {
    17  	jujutesting.JujuConnSuite
    18  	ctx upgrades.Context
    19  }
    20  
    21  var _ = gc.Suite(&rsyslogPortSuite{})
    22  
    23  func (s *rsyslogPortSuite) SetUpTest(c *gc.C) {
    24  	s.JujuConnSuite.SetUpTest(c)
    25  	apiState, _ := s.OpenAPIAsNewMachine(c, state.JobManageEnviron)
    26  	s.ctx = &mockContext{
    27  		agentConfig: &mockAgentConfig{
    28  			dataDir:   s.DataDir(),
    29  			mongoInfo: s.MongoInfo(c),
    30  		},
    31  		apiState: apiState,
    32  		state:    s.State,
    33  	}
    34  	cfg, err := s.State.EnvironConfig()
    35  	c.Assert(err, jc.ErrorIsNil)
    36  	c.Assert(cfg.SyslogPort(), gc.Not(gc.Equals), config.DefaultSyslogPort)
    37  }
    38  
    39  func (s *rsyslogPortSuite) TestSyslogPortChanged(c *gc.C) {
    40  	err := upgrades.UpdateRsyslogPort(s.ctx)
    41  	c.Assert(err, jc.ErrorIsNil)
    42  	cfg, err := s.State.EnvironConfig()
    43  	c.Assert(err, jc.ErrorIsNil)
    44  	c.Assert(cfg.SyslogPort(), gc.Equals, config.DefaultSyslogPort)
    45  }
    46  
    47  func (s *rsyslogPortSuite) TestIdempotent(c *gc.C) {
    48  	err := upgrades.UpdateRsyslogPort(s.ctx)
    49  	c.Assert(err, jc.ErrorIsNil)
    50  	err = upgrades.UpdateRsyslogPort(s.ctx)
    51  	c.Assert(err, jc.ErrorIsNil)
    52  	cfg, err := s.State.EnvironConfig()
    53  	c.Assert(err, jc.ErrorIsNil)
    54  	c.Assert(cfg.SyslogPort(), gc.Equals, config.DefaultSyslogPort)
    55  }