Left: | ||
Right: |
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 "strconv" | |
8 stdtesting "testing" | 7 stdtesting "testing" |
9 | 8 |
10 gc "launchpad.net/gocheck" | 9 gc "launchpad.net/gocheck" |
11 | 10 |
12 "launchpad.net/juju-core/charm" | 11 "launchpad.net/juju-core/charm" |
13 "launchpad.net/juju-core/errors" | 12 "launchpad.net/juju-core/errors" |
14 "launchpad.net/juju-core/instance" | 13 "launchpad.net/juju-core/instance" |
15 "launchpad.net/juju-core/juju/testing" | 14 "launchpad.net/juju-core/juju/testing" |
16 "launchpad.net/juju-core/state" | 15 "launchpad.net/juju-core/state" |
17 "launchpad.net/juju-core/state/api/params" | 16 "launchpad.net/juju-core/state/api/params" |
(...skipping 754 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
772 c.Assert(err, gc.IsNil) | 771 c.Assert(err, gc.IsNil) |
773 c.Assert(result, gc.DeepEquals, params.StringResults{ | 772 c.Assert(result, gc.DeepEquals, params.StringResults{ |
774 Results: []params.StringResult{ | 773 Results: []params.StringResult{ |
775 {Error: apiservertesting.ErrUnauthorized}, | 774 {Error: apiservertesting.ErrUnauthorized}, |
776 {Result: s.wpCharm.BundleSha256()}, | 775 {Result: s.wpCharm.BundleSha256()}, |
777 {Result: dummyCharm.BundleSha256()}, | 776 {Result: dummyCharm.BundleSha256()}, |
778 }, | 777 }, |
779 }) | 778 }) |
780 } | 779 } |
781 | 780 |
782 func (s *uniterSuite) TestEnvironUUID(c *gc.C) { | 781 func (s *uniterSuite) TestCurrentEnvironUUID(c *gc.C) { |
783 env, err := s.State.Environment() | 782 env, err := s.State.Environment() |
784 c.Assert(err, gc.IsNil) | 783 c.Assert(err, gc.IsNil) |
785 | 784 |
786 » args := params.Entities{Entities: []params.Entity{ | 785 » result, err := s.uniter.CurrentEnvironUUID() |
787 » » {Tag: "environment-foo"}, | 786 » c.Assert(err, gc.IsNil) |
788 » » {Tag: env.Tag()}, | 787 » c.Assert(result, gc.DeepEquals, params.StringResult{Result: env.UUID()}) |
fwereade
2013/08/15 15:57:29
Yeah, +10 to CurrentEnvironUUID. We should not be
dimitern
2013/08/15 16:56:56
Done.
| |
789 » » {Tag: "foo-bar"}, | |
790 » » {Tag: "service-foo"}, | |
791 » » {Tag: "unit-foo-0"}, | |
792 » }} | |
793 » result, err := s.uniter.EnvironUUID(args) | |
794 » c.Assert(err, gc.IsNil) | |
795 » c.Assert(result, gc.DeepEquals, params.StringResults{ | |
796 » » Results: []params.StringResult{ | |
797 » » » {Error: apiservertesting.ErrUnauthorized}, | |
798 » » » {Result: env.UUID()}, | |
799 » » » {Error: apiservertesting.ErrUnauthorized}, | |
800 » » » {Error: apiservertesting.ErrUnauthorized}, | |
801 » » » {Error: apiservertesting.ErrUnauthorized}, | |
802 » » }, | |
803 » }) | |
804 } | 788 } |
805 | 789 |
806 func (s *uniterSuite) TestRelation(c *gc.C) { | 790 func (s *uniterSuite) TestRelation(c *gc.C) { |
807 » s.addRelatedService(c, "wordpress", "logging", s.wordpressUnit) | 791 » eps, err := s.State.InferEndpoints([]string{"wordpress", "mysql"}) |
808 » rel, err := s.State.Relation(0) | 792 » c.Assert(err, gc.IsNil) |
809 » c.Assert(err, gc.IsNil) | 793 » rel, err := s.State.AddRelation(eps...) |
810 » relEps := rel.Endpoints() | 794 » c.Assert(err, gc.IsNil) |
811 » eps := make([]params.Endpoint, len(relEps)) | 795 » c.Assert(rel.Id(), gc.Equals, 0) |
812 » for i, ep := range relEps { | 796 » wpEp, err := rel.Endpoint("wordpress") |
813 » » eps[i] = params.Endpoint{ | 797 » c.Assert(err, gc.IsNil) |
814 » » » ServiceName: ep.ServiceName, | 798 |
815 » » » Relation: charm.Relation{ | 799 » args := params.Relations{Relations: []params.Relation{ |
816 » » » » Name: ep.Name, | 800 » » {Relation: "relation-42", Unit: "unit-foo-0"}, |
817 » » » » Role: ep.Role, | 801 » » {Relation: "relation-0", Unit: "unit-wordpress-0"}, |
818 » » » » Interface: ep.Interface, | 802 » » {Relation: "relation-0", Unit: "unit-mysql-0"}, |
819 » » » » Optional: ep.Optional, | 803 » » {Relation: "relation-0", Unit: "unit-foo-0"}, |
820 » » » » Limit: ep.Limit, | 804 » » {Relation: "relation-blah", Unit: "unit-wordpress-0"}, |
821 » » » » Scope: ep.Scope, | 805 » » {Relation: "service-foo", Unit: "user-admin"}, |
822 » » » }, | 806 » » {Relation: "foo", Unit: "bar"}, |
823 » » } | 807 » » {Relation: "unit-wordpress-0", Unit: "relation-0"}, |
824 » } | |
825 | |
826 » args := params.Entities{Entities: []params.Entity{ | |
827 » » {Tag: "relation-42"}, | |
828 » » {Tag: "relation-0"}, | |
829 » » {Tag: "relation-blah"}, | |
830 » » {Tag: "service-foo"}, | |
831 » » {Tag: "foo"}, | |
832 » » {Tag: "unit-wordpress-0"}, | |
833 }} | 808 }} |
834 result, err := s.uniter.Relation(args) | 809 result, err := s.uniter.Relation(args) |
835 c.Assert(err, gc.IsNil) | 810 c.Assert(err, gc.IsNil) |
811 c.Assert(result.Results, gc.HasLen, len(args.Relations)) | |
836 c.Assert(result, gc.DeepEquals, params.RelationResults{ | 812 c.Assert(result, gc.DeepEquals, params.RelationResults{ |
837 Results: []params.RelationResult{ | 813 Results: []params.RelationResult{ |
838 {Error: apiservertesting.ErrUnauthorized}, | 814 {Error: apiservertesting.ErrUnauthorized}, |
839 » » » {Id: strconv.Itoa(rel.Id()), Key: rel.String(), Endpoint s: eps}, | 815 » » » { |
840 » » » {Error: apiservertesting.ErrUnauthorized}, | 816 » » » » Id: rel.Id(), |
841 » » » {Error: apiservertesting.ErrUnauthorized}, | 817 » » » » Key: rel.String(), |
842 » » » {Error: apiservertesting.ErrUnauthorized}, | 818 » » » » Endpoint: params.Endpoint{ |
843 » » » {Error: apiservertesting.ErrUnauthorized}, | 819 » » » » » ServiceName: wpEp.ServiceName, |
844 » » }, | 820 » » » » » Relation: wpEp.Relation, |
845 » }) | 821 » » » » }, |
846 } | 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 |