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 agent_test | 4 package agent_test |
5 | 5 |
6 import ( | 6 import ( |
7 gc "launchpad.net/gocheck" | 7 gc "launchpad.net/gocheck" |
8 | 8 |
9 "launchpad.net/juju-core/agent" | 9 "launchpad.net/juju-core/agent" |
10 "launchpad.net/juju-core/testing/testbase" | 10 "launchpad.net/juju-core/testing/testbase" |
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
177 Nonce: "a nonce", | 177 Nonce: "a nonce", |
178 } | 178 } |
179 | 179 |
180 func (*suite) TestAttributes(c *gc.C) { | 180 func (*suite) TestAttributes(c *gc.C) { |
181 conf, err := agent.NewAgentConfig(attributeParams) | 181 conf, err := agent.NewAgentConfig(attributeParams) |
182 c.Assert(err, gc.IsNil) | 182 c.Assert(err, gc.IsNil) |
183 c.Assert(conf.DataDir(), gc.Equals, "/data/dir") | 183 c.Assert(conf.DataDir(), gc.Equals, "/data/dir") |
184 c.Assert(conf.Tag(), gc.Equals, "omg") | 184 c.Assert(conf.Tag(), gc.Equals, "omg") |
185 c.Assert(conf.Dir(), gc.Equals, "/data/dir/agents/omg") | 185 c.Assert(conf.Dir(), gc.Equals, "/data/dir/agents/omg") |
186 c.Assert(conf.Nonce(), gc.Equals, "a nonce") | 186 c.Assert(conf.Nonce(), gc.Equals, "a nonce") |
187 » c.Assert(conf.APIAddresses(), gc.DeepEquals, []string{"localhost:1235"}) | 187 } |
188 } | 188 |
189 | 189 func (s *suite) TestApiAddressesCantWriteBack(c *gc.C) { |
| 190 » conf, err := agent.NewAgentConfig(attributeParams) |
| 191 » c.Assert(err, gc.IsNil) |
| 192 » value, err := conf.APIAddresses() |
| 193 » c.Assert(err, gc.IsNil) |
| 194 » c.Assert(value, gc.DeepEquals, []string{"localhost:1235"}) |
| 195 » value[0] = "invalidAdr" |
| 196 » //Check out change hasn't gone back into the internals |
| 197 » newValue, err := conf.APIAddresses() |
| 198 » c.Assert(err, gc.IsNil) |
| 199 » c.Assert(newValue, gc.DeepEquals, []string{"localhost:1235"}) |
| 200 } |
190 func (*suite) TestWriteAndRead(c *gc.C) { | 201 func (*suite) TestWriteAndRead(c *gc.C) { |
191 testParams := attributeParams | 202 testParams := attributeParams |
192 testParams.DataDir = c.MkDir() | 203 testParams.DataDir = c.MkDir() |
193 conf, err := agent.NewAgentConfig(testParams) | 204 conf, err := agent.NewAgentConfig(testParams) |
194 c.Assert(err, gc.IsNil) | 205 c.Assert(err, gc.IsNil) |
195 | 206 |
196 c.Assert(conf.Write(), gc.IsNil) | 207 c.Assert(conf.Write(), gc.IsNil) |
197 reread, err := agent.ReadConf(conf.DataDir(), conf.Tag()) | 208 reread, err := agent.ReadConf(conf.DataDir(), conf.Tag()) |
198 c.Assert(err, gc.IsNil) | 209 c.Assert(err, gc.IsNil) |
199 // Since we can't directly poke the internals, we'll use the WriteComman
ds | 210 // Since we can't directly poke the internals, we'll use the WriteComman
ds |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
248 // Show that the password is saved. | 259 // Show that the password is saved. |
249 reread, err := agent.ReadConf(conf.DataDir(), conf.Tag()) | 260 reread, err := agent.ReadConf(conf.DataDir(), conf.Tag()) |
250 c.Assert(agent.Password(conf), gc.Equals, agent.Password(reread)
) | 261 c.Assert(agent.Password(conf), gc.Equals, agent.Password(reread)
) |
251 c.Assert(newPass, gc.Equals, agent.Password(conf)) | 262 c.Assert(newPass, gc.Equals, agent.Password(conf)) |
252 } | 263 } |
253 } | 264 } |
254 | 265 |
255 // Actual opening of state and api requires a lot more boiler plate to make | 266 // Actual opening of state and api requires a lot more boiler plate to make |
256 // sure they are valid connections. This is done in the cmd/jujud tests for | 267 // sure they are valid connections. This is done in the cmd/jujud tests for |
257 // bootstrap, machine and unit tests. | 268 // bootstrap, machine and unit tests. |
LEFT | RIGHT |