github.com/wallyworld/juju@v0.0.0-20161013125918-6cf1bc9d917a/worker/uniter/runner/jujuc/testing/unit.go (about)

     1  // Copyright 2015 Canonical Ltd.
     2  // Licensed under the AGPLv3, see LICENCE file for details.
     3  
     4  package testing
     5  
     6  import (
     7  	"github.com/juju/errors"
     8  	"gopkg.in/juju/charm.v6-unstable"
     9  )
    10  
    11  // Unit holds the values for the hook context.
    12  type Unit struct {
    13  	Name           string
    14  	ConfigSettings charm.Settings
    15  }
    16  
    17  // ContextUnit is a test double for jujuc.ContextUnit.
    18  type ContextUnit struct {
    19  	contextBase
    20  	info *Unit
    21  }
    22  
    23  // UnitName implements jujuc.ContextUnit.
    24  func (c *ContextUnit) UnitName() string {
    25  	c.stub.AddCall("UnitName")
    26  	c.stub.NextErr()
    27  
    28  	return c.info.Name
    29  }
    30  
    31  // ConfigSettings implements jujuc.ContextUnit.
    32  func (c *ContextUnit) ConfigSettings() (charm.Settings, error) {
    33  	c.stub.AddCall("ConfigSettings")
    34  	if err := c.stub.NextErr(); err != nil {
    35  		return nil, errors.Trace(err)
    36  	}
    37  
    38  	return c.info.ConfigSettings, nil
    39  }