70
70
// These are stub config values for use in tests.
72
72
ConfigAttrs = testing.FakeConfig().Merge(testing.Attrs{
79
"uuid": "2d02eeac-9dbb-11e4-89d3-123b93f75cba",
79
"uuid": "2d02eeac-9dbb-11e4-89d3-123b93f75cba",
80
"controller-uuid": "bfef02f1-932a-425a-a102-62175dcabd1d",
266
267
BaseSuiteUnpatched
268
269
Stub *gitjujutesting.Stub
270
271
Firewaller *stubFirewaller
271
272
Common *stubCommon
272
273
Policy *stubPolicy
276
func (s *BaseSuite) SetUpSuite(c *gc.C) {
277
s.BaseSuiteUnpatched.SetUpSuite(c)
278
// Do this *before* s.initEnv() gets called in BaseSuiteUnpatched.SetUpTest
279
s.PatchValue(&asNonLocal, s.asNonLocal)
275
282
func (s *BaseSuite) SetUpTest(c *gc.C) {
276
// Do this *before* s.initEnv() gets called.
277
s.PatchValue(&asNonLocal, s.asNonLocal)
279
283
s.BaseSuiteUnpatched.SetUpTest(c)
281
285
s.Stub = &gitjujutesting.Stub{}
282
s.Client = &stubClient{stub: s.Stub}
286
s.Client = &StubClient{Stub: s.Stub}
283
287
s.Firewaller = &stubFirewaller{stub: s.Stub}
284
288
s.Common = &stubCommon{stub: s.Stub}
285
289
s.Policy = &stubPolicy{stub: s.Stub}
470
474
return s.Arches, nil
473
type stubClient struct {
474
stub *gitjujutesting.Stub
477
type StubClient struct {
476
480
Insts []lxdclient.Instance
477
481
Inst *lxdclient.Instance
480
func (conn *stubClient) Instances(prefix string, statuses ...string) ([]lxdclient.Instance, error) {
481
conn.stub.AddCall("Instances", prefix, statuses)
482
if err := conn.stub.NextErr(); err != nil {
484
func (conn *StubClient) Instances(prefix string, statuses ...string) ([]lxdclient.Instance, error) {
485
conn.AddCall("Instances", prefix, statuses)
486
if err := conn.NextErr(); err != nil {
483
487
return nil, errors.Trace(err)
486
490
return conn.Insts, nil
489
func (conn *stubClient) AddInstance(spec lxdclient.InstanceSpec) (*lxdclient.Instance, error) {
490
conn.stub.AddCall("AddInstance", spec)
491
if err := conn.stub.NextErr(); err != nil {
493
func (conn *StubClient) AddInstance(spec lxdclient.InstanceSpec) (*lxdclient.Instance, error) {
494
conn.AddCall("AddInstance", spec)
495
if err := conn.NextErr(); err != nil {
492
496
return nil, errors.Trace(err)
495
499
return conn.Inst, nil
498
func (conn *stubClient) RemoveInstances(prefix string, ids ...string) error {
499
conn.stub.AddCall("RemoveInstances", prefix, ids)
500
if err := conn.stub.NextErr(); err != nil {
501
return errors.Trace(err)
507
func (conn *stubClient) EnsureImageExists(series string) error {
508
conn.stub.AddCall("EnsureImageExists", series)
509
if err := conn.stub.NextErr(); err != nil {
510
return errors.Trace(err)
516
func (conn *stubClient) Addresses(name string) ([]network.Address, error) {
517
conn.stub.AddCall("Addresses", name)
518
if err := conn.stub.NextErr(); err != nil {
502
func (conn *StubClient) RemoveInstances(prefix string, ids ...string) error {
503
conn.AddCall("RemoveInstances", prefix, ids)
504
if err := conn.NextErr(); err != nil {
505
return errors.Trace(err)
511
func (conn *StubClient) EnsureImageExists(series string, _ []lxdclient.Remote, _ func(string)) error {
512
conn.AddCall("EnsureImageExists", series)
513
if err := conn.NextErr(); err != nil {
514
return errors.Trace(err)
520
func (conn *StubClient) Addresses(name string) ([]network.Address, error) {
521
conn.AddCall("Addresses", name)
522
if err := conn.NextErr(); err != nil {
519
523
return nil, errors.Trace(err)