~nskaggs/+junk/xenial-test

« back to all changes in this revision

Viewing changes to src/github.com/juju/juju/worker/uniter/runner/jujuc/testing/unit.go

  • Committer: Nicholas Skaggs
  • Date: 2016-10-24 20:56:05 UTC
  • Revision ID: nicholas.skaggs@canonical.com-20161024205605-z8lta0uvuhtxwzwl
Initi with beta15

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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
}