github.com/cloud-green/juju@v0.0.0-20151002100041-a00291338d3d/cmd/jujud/agent/unit/manifolds_test.go (about)

     1  // Copyright 2015 Canonical Ltd.
     2  // Licensed under the AGPLv3, see LICENCE file for details.
     3  
     4  package unit_test
     5  
     6  import (
     7  	jc "github.com/juju/testing/checkers"
     8  	gc "gopkg.in/check.v1"
     9  
    10  	"github.com/juju/juju/agent"
    11  	"github.com/juju/juju/cmd/jujud/agent/unit"
    12  	"github.com/juju/juju/testing"
    13  	"github.com/juju/juju/worker/dependency"
    14  )
    15  
    16  type ManifoldsSuite struct {
    17  	testing.BaseSuite
    18  }
    19  
    20  var _ = gc.Suite(&ManifoldsSuite{})
    21  
    22  func (s *ManifoldsSuite) TestStartFuncs(c *gc.C) {
    23  	manifolds := unit.Manifolds(unit.ManifoldsConfig{
    24  		Agent: fakeAgent{},
    25  	})
    26  
    27  	for name, manifold := range manifolds {
    28  		c.Logf("checking %q manifold", name)
    29  		c.Check(manifold.Start, gc.NotNil)
    30  	}
    31  }
    32  
    33  // TODO(cmars) 2015/08/10: rework this into builtin Engine cycle checker.
    34  func (s *ManifoldsSuite) TestAcyclic(c *gc.C) {
    35  	manifolds := unit.Manifolds(unit.ManifoldsConfig{
    36  		Agent: fakeAgent{},
    37  	})
    38  	err := dependency.Validate(manifolds)
    39  	c.Assert(err, jc.ErrorIsNil)
    40  }
    41  
    42  func (s *ManifoldsSuite) TestManifoldNames(c *gc.C) {
    43  	config := unit.ManifoldsConfig{
    44  		Agent:               nil,
    45  		LogSource:           nil,
    46  		LeadershipGuarantee: 0,
    47  	}
    48  
    49  	manifolds := unit.Manifolds(config)
    50  	expectedKeys := []string{
    51  		unit.AgentName,
    52  		unit.APIAdddressUpdaterName,
    53  		unit.APICallerName,
    54  		unit.APIInfoGateName,
    55  		unit.LeadershipTrackerName,
    56  		unit.LoggingConfigUpdaterName,
    57  		unit.LogSenderName,
    58  		unit.MachineLockName,
    59  		unit.ProxyConfigUpdaterName,
    60  		unit.RsyslogConfigUpdaterName,
    61  		unit.UniterName,
    62  		unit.UpgraderName,
    63  		unit.MetricSpoolName,
    64  		unit.MetricCollectName,
    65  		unit.MetricSenderName,
    66  		unit.CharmDirName,
    67  	}
    68  	keys := make([]string, 0, len(manifolds))
    69  	for k := range manifolds {
    70  		keys = append(keys, k)
    71  	}
    72  	c.Assert(expectedKeys, jc.SameContents, keys)
    73  }
    74  
    75  type fakeAgent struct {
    76  	agent.Agent
    77  }