github.com/cloud-green/juju@v0.0.0-20151002100041-a00291338d3d/worker/conv2state/fakes_test.go (about)

     1  // Copyright 2015 Canonical Ltd.
     2  // Licensed under the AGPLv3, see LICENCE file for details.
     3  
     4  package conv2state
     5  
     6  import (
     7  	"github.com/juju/names"
     8  
     9  	"github.com/juju/juju/api/watcher"
    10  	"github.com/juju/juju/apiserver/params"
    11  )
    12  
    13  type fakeMachiner struct {
    14  	m      machine
    15  	err    error
    16  	gotTag names.MachineTag
    17  }
    18  
    19  func (f *fakeMachiner) Machine(tag names.MachineTag) (machine, error) {
    20  	f.gotTag = tag
    21  	return f.m, f.err
    22  }
    23  
    24  type fakeMachine struct {
    25  	jobs     *params.JobsResult
    26  	jobsErr  error
    27  	watchErr error
    28  	w        fakeWatcher
    29  }
    30  
    31  func (f fakeMachine) Jobs() (*params.JobsResult, error) {
    32  	return f.jobs, f.jobsErr
    33  }
    34  
    35  func (f fakeMachine) Watch() (watcher.NotifyWatcher, error) {
    36  	if f.watchErr == nil {
    37  		return f.w, nil
    38  	}
    39  	return nil, f.watchErr
    40  }
    41  
    42  type fakeWatcher struct{}
    43  
    44  func (fakeWatcher) Changes() <-chan struct{} {
    45  	return nil
    46  }
    47  
    48  func (fakeWatcher) Stop() error {
    49  	return nil
    50  }
    51  
    52  func (fakeWatcher) Err() error {
    53  	return nil
    54  }
    55  
    56  type fakeAgent struct {
    57  	tag        names.Tag
    58  	restartErr error
    59  	didRestart bool
    60  }
    61  
    62  func (f *fakeAgent) Restart() error {
    63  	f.didRestart = true
    64  	return f.restartErr
    65  }
    66  
    67  func (f fakeAgent) Tag() names.Tag {
    68  	return f.tag
    69  }