LEFT | RIGHT |
(no file at all) | |
1 package state_test | 1 package state_test |
2 | 2 |
3 import ( | 3 import ( |
4 "fmt" | 4 "fmt" |
5 . "launchpad.net/gocheck" | 5 . "launchpad.net/gocheck" |
6 "launchpad.net/gozk/zookeeper" | 6 "launchpad.net/gozk/zookeeper" |
7 "launchpad.net/juju/go/charm" | 7 "launchpad.net/juju/go/charm" |
8 "launchpad.net/juju/go/state" | 8 "launchpad.net/juju/go/state" |
9 "launchpad.net/juju/go/testing" | 9 "launchpad.net/juju/go/testing" |
10 "net/url" | 10 "net/url" |
(...skipping 1023 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1034 // Peer. | 1034 // Peer. |
1035 s.st.AddService("riak", dummy) | 1035 s.st.AddService("riak", dummy) |
1036 riakep := state.RelationEndpoint{"riak", "ring", "cache", state.RolePeer
, state.ScopeGlobal} | 1036 riakep := state.RelationEndpoint{"riak", "ring", "cache", state.RolePeer
, state.ScopeGlobal} |
1037 relation, serviceRelations, err = s.st.AddRelation(riakep) | 1037 relation, serviceRelations, err = s.st.AddRelation(riakep) |
1038 c.Assert(err, IsNil) | 1038 c.Assert(err, IsNil) |
1039 c.Assert(relation, NotNil) | 1039 c.Assert(relation, NotNil) |
1040 c.Assert(serviceRelations, HasLen, 1) | 1040 c.Assert(serviceRelations, HasLen, 1) |
1041 c.Assert(serviceRelations[0].RelationScope(), Equals, state.ScopeGlobal) | 1041 c.Assert(serviceRelations[0].RelationScope(), Equals, state.ScopeGlobal) |
1042 c.Assert(serviceRelations[0].RelationRole(), Equals, state.RolePeer) | 1042 c.Assert(serviceRelations[0].RelationRole(), Equals, state.RolePeer) |
1043 c.Assert(serviceRelations[0].RelationName(), Equals, "cache") | 1043 c.Assert(serviceRelations[0].RelationName(), Equals, "cache") |
1044 | |
1045 } | 1044 } |
1046 | 1045 |
1047 func (s *StateSuite) TestAddRelationMissingService(c *C) { | 1046 func (s *StateSuite) TestAddRelationMissingService(c *C) { |
1048 dummy := s.addDummyCharm(c) | 1047 dummy := s.addDummyCharm(c) |
1049 s.st.AddService("mysqldb", dummy) | 1048 s.st.AddService("mysqldb", dummy) |
1050 mysqlep := state.RelationEndpoint{"mysqldb", "blog", "db", state.RolePro
vider, state.ScopeGlobal} | 1049 mysqlep := state.RelationEndpoint{"mysqldb", "blog", "db", state.RolePro
vider, state.ScopeGlobal} |
1051 blogep := state.RelationEndpoint{"wordpress", "blog", "db", state.RoleRe
quirer, state.ScopeGlobal} | 1050 blogep := state.RelationEndpoint{"wordpress", "blog", "db", state.RoleRe
quirer, state.ScopeGlobal} |
1052 _, _, err := s.st.AddRelation(blogep, mysqlep) | 1051 _, _, err := s.st.AddRelation(blogep, mysqlep) |
1053 c.Assert(err, ErrorMatches, `service with name "wordpress" not found`) | 1052 c.Assert(err, ErrorMatches, `service with name "wordpress" not found`) |
1054 } | 1053 } |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1118 func (s *StateSuite) TestEnvironment(c *C) { | 1117 func (s *StateSuite) TestEnvironment(c *C) { |
1119 path, err := s.zkConn.Create("/environment", "type: dummy\nname: foo\n",
0, zookeeper.WorldACL(zookeeper.PERM_ALL)) | 1118 path, err := s.zkConn.Create("/environment", "type: dummy\nname: foo\n",
0, zookeeper.WorldACL(zookeeper.PERM_ALL)) |
1120 c.Assert(err, IsNil) | 1119 c.Assert(err, IsNil) |
1121 c.Assert(path, Equals, "/environment") | 1120 c.Assert(path, Equals, "/environment") |
1122 | 1121 |
1123 env, err := s.st.Environment() | 1122 env, err := s.st.Environment() |
1124 env.Read() | 1123 env.Read() |
1125 c.Assert(err, IsNil) | 1124 c.Assert(err, IsNil) |
1126 c.Assert(env.Map(), DeepEquals, map[string]interface{}{"type": "dummy",
"name": "foo"}) | 1125 c.Assert(env.Map(), DeepEquals, map[string]interface{}{"type": "dummy",
"name": "foo"}) |
1127 } | 1126 } |
| 1127 |
| 1128 func (s *StateSuite) TestAddRelationInvalidEndpoints(c *C) { |
| 1129 dummy := s.addDummyCharm(c) |
| 1130 s.st.AddService("riak", dummy) |
| 1131 // Empty service name. |
| 1132 riakep := state.RelationEndpoint{"", "ring", "cache", state.RolePeer, st
ate.ScopeGlobal} |
| 1133 _, _, err := s.st.AddRelation(riakep) |
| 1134 c.Assert(err, ErrorMatches, `endpoint has empty service name`) |
| 1135 // Empty interface. |
| 1136 riakep = state.RelationEndpoint{"riak", "", "cache", state.RolePeer, sta
te.ScopeGlobal} |
| 1137 _, _, err = s.st.AddRelation(riakep) |
| 1138 c.Assert(err, ErrorMatches, `endpoint has empty interface`) |
| 1139 // Empty relation name. |
| 1140 riakep = state.RelationEndpoint{"riak", "ring", "", state.RolePeer, stat
e.ScopeGlobal} |
| 1141 _, _, err = s.st.AddRelation(riakep) |
| 1142 c.Assert(err, ErrorMatches, `endpoint has empty relation name`) |
| 1143 // Invalid role. |
| 1144 riakep = state.RelationEndpoint{"riak", "ring", "cache", state.RelationR
ole("foo"), state.ScopeGlobal} |
| 1145 _, _, err = s.st.AddRelation(riakep) |
| 1146 c.Assert(err, ErrorMatches, `can't add non-peer relation with a single s
ervice`) |
| 1147 // Invalid role. |
| 1148 riakep = state.RelationEndpoint{"riak", "ring", "cache", state.RolePeer,
state.RelationScope("foo")} |
| 1149 _, _, err = s.st.AddRelation(riakep) |
| 1150 c.Assert(err, ErrorMatches, `endpoint has invalid scope: "foo"`) |
| 1151 } |
LEFT | RIGHT |