github.com/wallyworld/juju@v0.0.0-20161013125918-6cf1bc9d917a/worker/uniter/runcommands/mock_test.go (about) 1 // Copyright 2015 Canonical Ltd. 2 // Licensed under the AGPLv3, see LICENCE file for details. 3 4 package runcommands_test 5 6 import ( 7 "github.com/juju/testing" 8 "github.com/juju/utils/exec" 9 10 "github.com/juju/juju/worker/uniter/operation" 11 "github.com/juju/juju/worker/uniter/runner" 12 "github.com/juju/juju/worker/uniter/runner/context" 13 ) 14 15 type mockRunnerFactory struct { 16 runner.Factory 17 newCommandRunner func(context.CommandInfo) (runner.Runner, error) 18 } 19 20 func (f *mockRunnerFactory) NewCommandRunner(info context.CommandInfo) (runner.Runner, error) { 21 return f.newCommandRunner(info) 22 } 23 24 type mockRunner struct { 25 runner.Runner 26 runCommands func(string) (*exec.ExecResponse, error) 27 } 28 29 func (r *mockRunner) Context() runner.Context { 30 return &mockRunnerContext{} 31 } 32 33 func (r *mockRunner) RunCommands(commands string) (*exec.ExecResponse, error) { 34 return r.runCommands(commands) 35 } 36 37 type mockRunnerContext struct { 38 runner.Context 39 } 40 41 func (*mockRunnerContext) Prepare() error { 42 return nil 43 } 44 45 type mockCallbacks struct { 46 testing.Stub 47 operation.Callbacks 48 } 49 50 func (c *mockCallbacks) SetExecutingStatus(status string) error { 51 c.MethodCall(c, "SetExecutingStatus", status) 52 return c.NextErr() 53 }