github.com/wallyworld/juju@v0.0.0-20161013125918-6cf1bc9d917a/worker/machiner/mock_test.go (about)

     1  // Copyright 2015 Canonical Ltd.
     2  // Licensed under the AGPLv3, see LICENCE file for details.
     3  
     4  package machiner_test
     5  
     6  import (
     7  	gitjujutesting "github.com/juju/testing"
     8  	"gopkg.in/juju/names.v2"
     9  
    10  	"github.com/juju/juju/apiserver/params"
    11  	"github.com/juju/juju/network"
    12  	"github.com/juju/juju/status"
    13  	"github.com/juju/juju/watcher"
    14  	"github.com/juju/juju/worker/machiner"
    15  )
    16  
    17  type mockWatcher struct {
    18  	changes chan struct{}
    19  }
    20  
    21  func (w *mockWatcher) Changes() watcher.NotifyChannel {
    22  	return w.changes
    23  }
    24  
    25  func (w *mockWatcher) Kill() {}
    26  
    27  func (w *mockWatcher) Wait() error {
    28  	return nil
    29  }
    30  
    31  type mockMachine struct {
    32  	machiner.Machine
    33  	gitjujutesting.Stub
    34  	watcher mockWatcher
    35  	life    params.Life
    36  }
    37  
    38  func (m *mockMachine) Refresh() error {
    39  	m.MethodCall(m, "Refresh")
    40  	return m.NextErr()
    41  }
    42  
    43  func (m *mockMachine) Life() params.Life {
    44  	m.MethodCall(m, "Life")
    45  	return m.life
    46  }
    47  
    48  func (m *mockMachine) EnsureDead() error {
    49  	m.MethodCall(m, "EnsureDead")
    50  	return m.NextErr()
    51  }
    52  
    53  func (m *mockMachine) SetMachineAddresses(addresses []network.Address) error {
    54  	m.MethodCall(m, "SetMachineAddresses", addresses)
    55  	return m.NextErr()
    56  }
    57  
    58  func (m *mockMachine) SetObservedNetworkConfig(netConfig []params.NetworkConfig) error {
    59  	m.MethodCall(m, "SetObservedNetworkConfig", netConfig)
    60  	return m.NextErr()
    61  }
    62  
    63  func (m *mockMachine) SetStatus(status status.Status, info string, data map[string]interface{}) error {
    64  	m.MethodCall(m, "SetStatus", status, info, data)
    65  	return m.NextErr()
    66  }
    67  
    68  func (m *mockMachine) Watch() (watcher.NotifyWatcher, error) {
    69  	m.MethodCall(m, "Watch")
    70  	if err := m.NextErr(); err != nil {
    71  		return nil, err
    72  	}
    73  	return &m.watcher, nil
    74  }
    75  
    76  type mockMachineAccessor struct {
    77  	gitjujutesting.Stub
    78  	machine mockMachine
    79  }
    80  
    81  func (a *mockMachineAccessor) Machine(tag names.MachineTag) (machiner.Machine, error) {
    82  	a.MethodCall(a, "Machine", tag)
    83  	if err := a.NextErr(); err != nil {
    84  		return nil, err
    85  	}
    86  	return &a.machine, nil
    87  }