LEFT | RIGHT |
1 // Copyright 2013 Canonical Ltd. | 1 // Copyright 2013 Canonical Ltd. |
2 // Licensed under the AGPLv3, see LICENCE file for details. | 2 // Licensed under the AGPLv3, see LICENCE file for details. |
3 | 3 |
4 package uniter_test | 4 package uniter_test |
5 | 5 |
6 import ( | 6 import ( |
7 stdtesting "testing" | 7 stdtesting "testing" |
8 | 8 |
9 gc "launchpad.net/gocheck" | 9 gc "launchpad.net/gocheck" |
10 | 10 |
(...skipping 770 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
781 func (s *uniterSuite) TestCurrentEnvironUUID(c *gc.C) { | 781 func (s *uniterSuite) TestCurrentEnvironUUID(c *gc.C) { |
782 env, err := s.State.Environment() | 782 env, err := s.State.Environment() |
783 c.Assert(err, gc.IsNil) | 783 c.Assert(err, gc.IsNil) |
784 | 784 |
785 result, err := s.uniter.CurrentEnvironUUID() | 785 result, err := s.uniter.CurrentEnvironUUID() |
786 c.Assert(err, gc.IsNil) | 786 c.Assert(err, gc.IsNil) |
787 c.Assert(result, gc.DeepEquals, params.StringResult{Result: env.UUID()}) | 787 c.Assert(result, gc.DeepEquals, params.StringResult{Result: env.UUID()}) |
788 } | 788 } |
789 | 789 |
790 func (s *uniterSuite) TestRelation(c *gc.C) { | 790 func (s *uniterSuite) TestRelation(c *gc.C) { |
791 » s.addRelatedService(c, "wordpress", "logging", s.wordpressUnit) | 791 » eps, err := s.State.InferEndpoints([]string{"wordpress", "mysql"}) |
792 » rel, err := s.State.Relation(0) | 792 » c.Assert(err, gc.IsNil) |
793 » c.Assert(err, gc.IsNil) | 793 » rel, err := s.State.AddRelation(eps...) |
794 » relEps := rel.Endpoints() | 794 » c.Assert(err, gc.IsNil) |
795 » eps := make([]params.Endpoint, len(relEps)) | 795 » c.Assert(rel.Id(), gc.Equals, 0) |
796 » for i, ep := range relEps { | 796 » wpEp, err := rel.Endpoint("wordpress") |
797 » » eps[i] = params.Endpoint{ | 797 » c.Assert(err, gc.IsNil) |
798 » » » ServiceName: ep.ServiceName, | 798 |
799 » » » Relation: ep.Relation, | 799 » args := params.Relations{Relations: []params.Relation{ |
800 » » } | 800 » » {Relation: "relation-42", Unit: "unit-foo-0"}, |
801 » } | 801 » » {Relation: "relation-0", Unit: "unit-wordpress-0"}, |
802 | 802 » » {Relation: "relation-0", Unit: "unit-mysql-0"}, |
803 » args := params.Entities{Entities: []params.Entity{ | 803 » » {Relation: "relation-0", Unit: "unit-foo-0"}, |
804 » » {Tag: "relation-42"}, | 804 » » {Relation: "relation-blah", Unit: "unit-wordpress-0"}, |
805 » » {Tag: "relation-0"}, | 805 » » {Relation: "service-foo", Unit: "user-admin"}, |
806 » » {Tag: "relation-blah"}, | 806 » » {Relation: "foo", Unit: "bar"}, |
807 » » {Tag: "service-foo"}, | 807 » » {Relation: "unit-wordpress-0", Unit: "relation-0"}, |
808 » » {Tag: "foo"}, | |
809 » » {Tag: "unit-wordpress-0"}, | |
810 }} | 808 }} |
811 result, err := s.uniter.Relation(args) | 809 result, err := s.uniter.Relation(args) |
812 c.Assert(err, gc.IsNil) | 810 c.Assert(err, gc.IsNil) |
| 811 c.Assert(result.Results, gc.HasLen, len(args.Relations)) |
813 c.Assert(result, gc.DeepEquals, params.RelationResults{ | 812 c.Assert(result, gc.DeepEquals, params.RelationResults{ |
814 Results: []params.RelationResult{ | 813 Results: []params.RelationResult{ |
815 {Error: apiservertesting.ErrUnauthorized}, | 814 {Error: apiservertesting.ErrUnauthorized}, |
816 » » » {Id: rel.Id(), Key: rel.String(), Endpoints: eps}, | 815 » » » { |
817 » » » {Error: apiservertesting.ErrUnauthorized}, | 816 » » » » Id: rel.Id(), |
818 » » » {Error: apiservertesting.ErrUnauthorized}, | 817 » » » » Key: rel.String(), |
819 » » » {Error: apiservertesting.ErrUnauthorized}, | 818 » » » » Endpoint: params.Endpoint{ |
820 » » » {Error: apiservertesting.ErrUnauthorized}, | 819 » » » » » ServiceName: wpEp.ServiceName, |
821 » » }, | 820 » » » » » Relation: wpEp.Relation, |
822 » }) | 821 » » » » }, |
823 } | 822 » » » }, |
| 823 » » » {Error: apiservertesting.ErrUnauthorized}, |
| 824 » » » {Error: apiservertesting.ErrUnauthorized}, |
| 825 » » » {Error: apiservertesting.ErrUnauthorized}, |
| 826 » » » {Error: apiservertesting.ErrUnauthorized}, |
| 827 » » » {Error: apiservertesting.ErrUnauthorized}, |
| 828 » » » {Error: apiservertesting.ErrUnauthorized}, |
| 829 » » }, |
| 830 » }) |
| 831 } |
LEFT | RIGHT |