github.com/makyo/juju@v0.0.0-20160425123129-2608902037e9/resource/resourcetesting/state.go (about)

     1  // Copyright 2016 Canonical Ltd.
     2  // Licensed under the AGPLv3, see LICENCE file for details.
     3  
     4  package resourcetesting
     5  
     6  import (
     7  	"github.com/juju/testing"
     8  	"gopkg.in/juju/charm.v6-unstable"
     9  )
    10  
    11  // StubUnit is a testing implementation of resource.Unit.
    12  type StubUnit struct {
    13  	*testing.Stub
    14  
    15  	ReturnName        string
    16  	ReturnServiceName string
    17  	ReturnCharmURL    *charm.URL
    18  }
    19  
    20  // Name implements resource.Unit.
    21  func (s *StubUnit) Name() string {
    22  	s.AddCall("Name")
    23  	s.NextErr() // Pop one off.
    24  
    25  	return s.ReturnName
    26  }
    27  
    28  // ServiceName implements resource.Unit.
    29  func (s *StubUnit) ServiceName() string {
    30  	s.AddCall("ServiceName")
    31  	s.NextErr() // Pop one off.
    32  
    33  	return s.ReturnServiceName
    34  }
    35  
    36  // CharmURL implements resource.Unit.
    37  func (s *StubUnit) CharmURL() (*charm.URL, bool) {
    38  	s.AddCall("CharmURL")
    39  	s.NextErr() // Pop one off.
    40  
    41  	forceCharm := false
    42  	return s.ReturnCharmURL, forceCharm
    43  }