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

     1  // Copyright 2012, 2013 Canonical Ltd.
     2  // Licensed under the AGPLv3, see LICENCE file for details.
     3  
     4  package state
     5  
     6  import (
     7  	jc "github.com/juju/testing/checkers"
     8  	gc "gopkg.in/check.v1"
     9  	"gopkg.in/juju/charm.v6-unstable"
    10  )
    11  
    12  type RelationSuite struct{}
    13  
    14  var _ = gc.Suite(&RelationSuite{})
    15  
    16  // TestRelatedEndpoints verifies the behaviour of RelatedEndpoints in
    17  // multi-endpoint peer relations, which are currently not constructable
    18  // by normal means.
    19  func (s *RelationSuite) TestRelatedEndpoints(c *gc.C) {
    20  	rel := charm.Relation{
    21  		Interface: "ifce",
    22  		Name:      "group",
    23  		Role:      charm.RolePeer,
    24  		Scope:     charm.ScopeGlobal,
    25  	}
    26  	eps := []Endpoint{{
    27  		ApplicationName: "jeff",
    28  		Relation:        rel,
    29  	}, {
    30  		ApplicationName: "mike",
    31  		Relation:        rel,
    32  	}, {
    33  		ApplicationName: "mike",
    34  		Relation:        rel,
    35  	}}
    36  	r := &Relation{nil, relationDoc{Endpoints: eps}}
    37  	relatedEps, err := r.RelatedEndpoints("mike")
    38  	c.Assert(err, jc.ErrorIsNil)
    39  	c.Assert(relatedEps, gc.DeepEquals, eps)
    40  }