Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(982)

Side by Side Diff: agent/agent_test.go

Issue 28970043: Added apiaddresses call to agent config
Patch Set: Added apiaddresses call to agent config Created 10 years, 4 months ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « agent/agent.go ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 155 matching lines...) Expand 10 before | Expand all | Expand 10 after
166 } 166 }
167 } 167 }
168 } 168 }
169 169
170 var attributeParams = agent.AgentConfigParams{ 170 var attributeParams = agent.AgentConfigParams{
171 DataDir: "/data/dir", 171 DataDir: "/data/dir",
172 Tag: "omg", 172 Tag: "omg",
173 Password: "sekrit", 173 Password: "sekrit",
174 CACert: []byte("ca cert"), 174 CACert: []byte("ca cert"),
175 StateAddresses: []string{"localhost:1234"}, 175 StateAddresses: []string{"localhost:1234"},
176 APIAddresses: []string{"localhost:1235"},
176 Nonce: "a nonce", 177 Nonce: "a nonce",
177 } 178 }
178 179
179 func (*suite) TestAttributes(c *gc.C) { 180 func (*suite) TestAttributes(c *gc.C) {
180 conf, err := agent.NewAgentConfig(attributeParams) 181 conf, err := agent.NewAgentConfig(attributeParams)
181 c.Assert(err, gc.IsNil) 182 c.Assert(err, gc.IsNil)
182 c.Assert(conf.DataDir(), gc.Equals, "/data/dir") 183 c.Assert(conf.DataDir(), gc.Equals, "/data/dir")
183 c.Assert(conf.Tag(), gc.Equals, "omg") 184 c.Assert(conf.Tag(), gc.Equals, "omg")
184 c.Assert(conf.Dir(), gc.Equals, "/data/dir/agents/omg") 185 c.Assert(conf.Dir(), gc.Equals, "/data/dir/agents/omg")
185 c.Assert(conf.Nonce(), gc.Equals, "a nonce") 186 c.Assert(conf.Nonce(), gc.Equals, "a nonce")
186 } 187 }
187 188
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 }
188 func (*suite) TestWriteAndRead(c *gc.C) { 201 func (*suite) TestWriteAndRead(c *gc.C) {
189 testParams := attributeParams 202 testParams := attributeParams
190 testParams.DataDir = c.MkDir() 203 testParams.DataDir = c.MkDir()
191 conf, err := agent.NewAgentConfig(testParams) 204 conf, err := agent.NewAgentConfig(testParams)
192 c.Assert(err, gc.IsNil) 205 c.Assert(err, gc.IsNil)
193 206
194 c.Assert(conf.Write(), gc.IsNil) 207 c.Assert(conf.Write(), gc.IsNil)
195 reread, err := agent.ReadConf(conf.DataDir(), conf.Tag()) 208 reread, err := agent.ReadConf(conf.DataDir(), conf.Tag())
196 c.Assert(err, gc.IsNil) 209 c.Assert(err, gc.IsNil)
197 // 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
246 // Show that the password is saved. 259 // Show that the password is saved.
247 reread, err := agent.ReadConf(conf.DataDir(), conf.Tag()) 260 reread, err := agent.ReadConf(conf.DataDir(), conf.Tag())
248 c.Assert(agent.Password(conf), gc.Equals, agent.Password(reread) ) 261 c.Assert(agent.Password(conf), gc.Equals, agent.Password(reread) )
249 c.Assert(newPass, gc.Equals, agent.Password(conf)) 262 c.Assert(newPass, gc.Equals, agent.Password(conf))
250 } 263 }
251 } 264 }
252 265
253 // 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
254 // 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
255 // bootstrap, machine and unit tests. 268 // bootstrap, machine and unit tests.
OLDNEW
« no previous file with comments | « agent/agent.go ('k') | no next file » | no next file with comments »

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b