LEFT | RIGHT |
1 package openstack_test | 1 package openstack_test |
2 | 2 |
3 import ( | 3 import ( |
4 "crypto/rand" | 4 "crypto/rand" |
5 "fmt" | 5 "fmt" |
6 "io" | 6 "io" |
7 . "launchpad.net/gocheck" | 7 . "launchpad.net/gocheck" |
8 "launchpad.net/goose/client" | 8 "launchpad.net/goose/client" |
9 "launchpad.net/goose/identity" | 9 "launchpad.net/goose/identity" |
10 "launchpad.net/goose/nova" | 10 "launchpad.net/goose/nova" |
11 "launchpad.net/juju-core/environs" | 11 "launchpad.net/juju-core/environs" |
12 "launchpad.net/juju-core/environs/jujutest" | 12 "launchpad.net/juju-core/environs/jujutest" |
| 13 "launchpad.net/juju-core/state" |
13 coretesting "launchpad.net/juju-core/testing" | 14 coretesting "launchpad.net/juju-core/testing" |
14 ) | 15 ) |
15 | 16 |
16 // uniqueName is generated afresh for every test run, so that | 17 // uniqueName is generated afresh for every test run, so that |
17 // we are not polluted by previous test state. | 18 // we are not polluted by previous test state. |
18 var uniqueName = randomName() | 19 var uniqueName = randomName() |
19 | 20 |
20 func randomName() string { | 21 func randomName() string { |
21 buf := make([]byte, 8) | 22 buf := make([]byte, 8) |
22 _, err := io.ReadFull(rand.Reader, buf) | 23 _, err := io.ReadFull(rand.Reader, buf) |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
124 return instances, nil | 125 return instances, nil |
125 } | 126 } |
126 | 127 |
127 func (t *LiveTests) TestAllInstances(c *C) { | 128 func (t *LiveTests) TestAllInstances(c *C) { |
128 // TODO FIXME These instances were not started by the environment, and h
ave no indication that they | 129 // TODO FIXME These instances were not started by the environment, and h
ave no indication that they |
129 // should be part of it. | 130 // should be part of it. |
130 observedInst, err := t.Env.AllInstances() | 131 observedInst, err := t.Env.AllInstances() |
131 c.Assert(err, IsNil) | 132 c.Assert(err, IsNil) |
132 idSet := make(map[string]bool) | 133 idSet := make(map[string]bool) |
133 for _, inst := range observedInst { | 134 for _, inst := range observedInst { |
134 » » idSet[inst.Id()] = true | 135 » » idSet[string(inst.Id())] = true |
135 } | 136 } |
136 for _, inst := range t.testServers { | 137 for _, inst := range t.testServers { |
137 _, ok := idSet[inst.Id] | 138 _, ok := idSet[inst.Id] |
138 if !ok { | 139 if !ok { |
139 c.Logf("Server id '%s' was not listed in AllInstances %v
", inst.Id, observedInst) | 140 c.Logf("Server id '%s' was not listed in AllInstances %v
", inst.Id, observedInst) |
140 c.Fail() | 141 c.Fail() |
141 } | 142 } |
142 } | 143 } |
143 } | 144 } |
144 | 145 |
145 func (t *LiveTests) TestInstances(c *C) { | 146 func (t *LiveTests) TestInstances(c *C) { |
146 // TODO FIXME These instances were not started by the environment, and h
ave no indication that they | 147 // TODO FIXME These instances were not started by the environment, and h
ave no indication that they |
147 // should be part of it. | 148 // should be part of it. |
148 » observedInst, err := t.Env.Instances([]string{t.testServers[0].Id}) | 149 » observedInst, err := t.Env.Instances([]state.InstanceId{state.InstanceId
(t.testServers[0].Id)}) |
149 c.Assert(err, IsNil) | 150 c.Assert(err, IsNil) |
150 c.Assert(len(observedInst), Equals, 1) | 151 c.Assert(len(observedInst), Equals, 1) |
151 » c.Assert(observedInst[0].Id(), Equals, t.testServers[0].Id) | 152 » c.Assert(string(observedInst[0].Id()), Equals, t.testServers[0].Id) |
152 } | 153 } |
LEFT | RIGHT |