OLD | NEW |
1 // Copyright 2012, 2013 Canonical Ltd. | 1 // Copyright 2012, 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 state_test | 4 package state_test |
5 | 5 |
6 import ( | 6 import ( |
7 . "launchpad.net/gocheck" | 7 . "launchpad.net/gocheck" |
8 "launchpad.net/juju-core/constraints" | 8 "launchpad.net/juju-core/constraints" |
9 "launchpad.net/juju-core/errors" | 9 "launchpad.net/juju-core/errors" |
10 "launchpad.net/juju-core/state" | 10 "launchpad.net/juju-core/state" |
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
185 func (s *MachineSuite) TestTag(c *C) { | 185 func (s *MachineSuite) TestTag(c *C) { |
186 c.Assert(s.machine.Tag(), Equals, "machine-0") | 186 c.Assert(s.machine.Tag(), Equals, "machine-0") |
187 } | 187 } |
188 | 188 |
189 func (s *MachineSuite) TestMachineTag(c *C) { | 189 func (s *MachineSuite) TestMachineTag(c *C) { |
190 c.Assert(state.MachineTag("10"), Equals, "machine-10") | 190 c.Assert(state.MachineTag("10"), Equals, "machine-10") |
191 // Check a container id. | 191 // Check a container id. |
192 c.Assert(state.MachineTag("10/lxc/1"), Equals, "machine-10-lxc-1") | 192 c.Assert(state.MachineTag("10/lxc/1"), Equals, "machine-10-lxc-1") |
193 } | 193 } |
194 | 194 |
| 195 func (s *MachineSuite) TestMachineIdFromTag(c *C) { |
| 196 c.Assert(state.MachineIdFromTag("machine-10"), Equals, "10") |
| 197 // Check a container id. |
| 198 c.Assert(state.MachineIdFromTag("machine-10-lxc-1"), Equals, "10/lxc/1") |
| 199 // Check reversability. |
| 200 nested := "2/kvm/0/lxc/3" |
| 201 c.Assert(state.MachineIdFromTag(state.MachineTag(nested)), Equals, neste
d) |
| 202 } |
| 203 |
195 func (s *MachineSuite) TestSetMongoPassword(c *C) { | 204 func (s *MachineSuite) TestSetMongoPassword(c *C) { |
196 testSetMongoPassword(c, func(st *state.State) (entity, error) { | 205 testSetMongoPassword(c, func(st *state.State) (entity, error) { |
197 return st.Machine(s.machine.Id()) | 206 return st.Machine(s.machine.Id()) |
198 }) | 207 }) |
199 } | 208 } |
200 | 209 |
201 func (s *MachineSuite) TestSetPassword(c *C) { | 210 func (s *MachineSuite) TestSetPassword(c *C) { |
202 testSetPassword(c, func() (state.Authenticator, error) { | 211 testSetPassword(c, func() (state.Authenticator, error) { |
203 return s.State.Machine(s.machine.Id()) | 212 return s.State.Machine(s.machine.Id()) |
204 }) | 213 }) |
(...skipping 693 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
898 c.Assert(status, Equals, params.StatusStopped) | 907 c.Assert(status, Equals, params.StatusStopped) |
899 c.Assert(info, Equals, "") | 908 c.Assert(info, Equals, "") |
900 | 909 |
901 err = s.machine.Remove() | 910 err = s.machine.Remove() |
902 c.Assert(err, IsNil) | 911 c.Assert(err, IsNil) |
903 err = s.machine.SetStatus(params.StatusStarted, "not really") | 912 err = s.machine.SetStatus(params.StatusStarted, "not really") |
904 c.Assert(err, ErrorMatches, `cannot set status of machine "0": not found
or not alive`) | 913 c.Assert(err, ErrorMatches, `cannot set status of machine "0": not found
or not alive`) |
905 _, _, err = s.machine.Status() | 914 _, _, err = s.machine.Status() |
906 c.Assert(err, ErrorMatches, "status not found") | 915 c.Assert(err, ErrorMatches, "status not found") |
907 } | 916 } |
OLD | NEW |