github.com/niedbalski/juju@v0.0.0-20190215020005-8ff100488e47/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  	"gopkg.in/juju/names.v2"
     8  
     9  	"github.com/juju/juju/apiserver/params"
    10  	"github.com/juju/juju/core/watcher"
    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() watcher.NotifyChannel {
    45  	return nil
    46  }
    47  
    48  func (fakeWatcher) Kill() {
    49  }
    50  
    51  func (fakeWatcher) Wait() error {
    52  	return nil
    53  }
    54  
    55  type fakeAgent struct {
    56  	tag names.Tag
    57  }
    58  
    59  func (f fakeAgent) Tag() names.Tag {
    60  	return f.tag
    61  }