~nskaggs/+junk/xenial-test

« back to all changes in this revision

Viewing changes to src/github.com/juju/juju/worker/uniter/resolver/mock_test.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 resolver_test
 
5
 
 
6
import (
 
7
        "github.com/juju/testing"
 
8
        "gopkg.in/juju/charm.v6-unstable"
 
9
 
 
10
        "github.com/juju/juju/worker/fortress"
 
11
        "github.com/juju/juju/worker/uniter/hook"
 
12
        "github.com/juju/juju/worker/uniter/operation"
 
13
        "github.com/juju/juju/worker/uniter/remotestate"
 
14
)
 
15
 
 
16
type mockRemoteStateWatcher struct {
 
17
        remotestate.RemoteStateWatcher
 
18
        changes  chan struct{}
 
19
        snapshot remotestate.Snapshot
 
20
}
 
21
 
 
22
func (w *mockRemoteStateWatcher) RemoteStateChanged() <-chan struct{} {
 
23
        return w.changes
 
24
}
 
25
 
 
26
func (w *mockRemoteStateWatcher) Snapshot() remotestate.Snapshot {
 
27
        return w.snapshot
 
28
}
 
29
 
 
30
type mockOpFactory struct {
 
31
        operation.Factory
 
32
        testing.Stub
 
33
        op mockOp
 
34
}
 
35
 
 
36
func (f *mockOpFactory) NewUpgrade(charmURL *charm.URL) (operation.Operation, error) {
 
37
        f.MethodCall(f, "NewUpgrade", charmURL)
 
38
        return f.op, f.NextErr()
 
39
}
 
40
 
 
41
func (f *mockOpFactory) NewRevertUpgrade(charmURL *charm.URL) (operation.Operation, error) {
 
42
        f.MethodCall(f, "NewRevertUpgrade", charmURL)
 
43
        return f.op, f.NextErr()
 
44
}
 
45
 
 
46
func (f *mockOpFactory) NewResolvedUpgrade(charmURL *charm.URL) (operation.Operation, error) {
 
47
        f.MethodCall(f, "NewResolvedUpgrade", charmURL)
 
48
        return f.op, f.NextErr()
 
49
}
 
50
 
 
51
func (f *mockOpFactory) NewRunHook(info hook.Info) (operation.Operation, error) {
 
52
        f.MethodCall(f, "NewRunHook", info)
 
53
        return f.op, f.NextErr()
 
54
}
 
55
 
 
56
func (f *mockOpFactory) NewSkipHook(info hook.Info) (operation.Operation, error) {
 
57
        f.MethodCall(f, "NewSkipHook", info)
 
58
        return f.op, f.NextErr()
 
59
}
 
60
 
 
61
func (f *mockOpFactory) NewAction(id string) (operation.Operation, error) {
 
62
        f.MethodCall(f, "NewAction", id)
 
63
        return f.op, f.NextErr()
 
64
}
 
65
 
 
66
type mockOpExecutor struct {
 
67
        operation.Executor
 
68
        testing.Stub
 
69
        st operation.State
 
70
}
 
71
 
 
72
func (e *mockOpExecutor) State() operation.State {
 
73
        e.MethodCall(e, "State")
 
74
        return e.st
 
75
}
 
76
 
 
77
func (e *mockOpExecutor) Run(op operation.Operation) error {
 
78
        e.MethodCall(e, "Run", op)
 
79
        return e.NextErr()
 
80
}
 
81
 
 
82
type mockOp struct {
 
83
        operation.Operation
 
84
        commit func(operation.State) (*operation.State, error)
 
85
}
 
86
 
 
87
func (op mockOp) Commit(st operation.State) (*operation.State, error) {
 
88
        if op.commit != nil {
 
89
                return op.commit(st)
 
90
        }
 
91
        return &st, nil
 
92
}
 
93
 
 
94
type mockCharmDirGuard struct {
 
95
        fortress.Guard
 
96
        testing.Stub
 
97
        commit func(operation.State) (*operation.State, error)
 
98
}
 
99
 
 
100
func (l *mockCharmDirGuard) Unlock() error {
 
101
        l.MethodCall(l, "Unlock")
 
102
        return l.NextErr()
 
103
}
 
104
 
 
105
func (l *mockCharmDirGuard) Lockdown(abort fortress.Abort) error {
 
106
        l.MethodCall(l, "Lockdown", abort)
 
107
        return l.NextErr()
 
108
}