Index: juju/dummyprovider_test.go |
=== roger.peppe@canonical.com-20111116163854-05vsxizrv13b83r8 > roger.peppe@canonical.com-20111201082157-c2fu7qxeuuyttdja |
=== modified file 'juju/dummyprovider_test.go' |
--- juju/dummyprovider_test.go 2011-11-08 16:26:58 +0000 |
+++ juju/dummyprovider_test.go 2011-12-01 08:21:57 +0000 |
@@ -18,16 +18,15 @@ |
juju.RegisterProvider("dummy", dummyProvider{}) |
} |
-type dummyMachine struct { |
+type dummyInstance struct { |
name string |
- id int |
-} |
- |
-func (m *dummyMachine) Id() string { |
- return fmt.Sprintf("dummy-%d", m.id) |
-} |
- |
-func (m *dummyMachine) DNSName() string { |
+} |
+ |
+func (m *dummyInstance) Id() string { |
+ return fmt.Sprintf("dummy-%s", m.name) |
+} |
+ |
+func (m *dummyInstance) DNSName() string { |
return m.name |
} |
@@ -46,15 +45,16 @@ |
type dummyEnviron struct { |
mu sync.Mutex |
baseName string |
- n int // machine count |
- machines map[int]*dummyMachine |
+ n int // instance count |
+ |
+ machines map[string]*dummyInstance |
} |
func (dummyProvider) Open(name string, attributes interface{}) (e juju.Environ, err error) { |
cfg := attributes.(schema.MapType) |
return &dummyEnviron{ |
baseName: cfg["basename"].(string), |
- machines: make(map[int]*dummyMachine), |
+ machines: make(map[string]*dummyInstance), |
}, nil |
} |
@@ -66,33 +66,32 @@ |
return nil |
} |
-func (c *dummyEnviron) StartMachine() (juju.Machine, error) { |
+func (c *dummyEnviron) StartInstance(id int) (juju.Instance, error) { |
c.mu.Lock() |
defer c.mu.Unlock() |
- m := &dummyMachine{ |
+ i := &dummyInstance{ |
name: fmt.Sprintf("%s-%d", c.baseName, c.n), |
- id: c.n, |
} |
- c.machines[m.id] = m |
+ c.machines[i.name] = i |
c.n++ |
- return m, nil |
+ return i, nil |
} |
-func (c *dummyEnviron) StopMachines(ms []juju.Machine) error { |
+func (c *dummyEnviron) StopInstances(is []juju.Instance) error { |
c.mu.Lock() |
defer c.mu.Unlock() |
- for _, m := range ms { |
- delete(c.machines, m.(*dummyMachine).id) |
+ for _, i := range is { |
+ delete(c.machines, i.(*dummyInstance).name) |
} |
return nil |
} |
-func (c *dummyEnviron) Machines() ([]juju.Machine, error) { |
+func (c *dummyEnviron) Instances() ([]juju.Instance, error) { |
c.mu.Lock() |
defer c.mu.Unlock() |
- var ms []juju.Machine |
- for _, m := range c.machines { |
- ms = append(ms, m) |
+ var is []juju.Instance |
+ for _, i := range c.machines { |
+ is = append(is, i) |
} |
- return ms, nil |
+ return is, nil |
} |