1
// Copyright 2015 Canonical Ltd.
2
// Licensed under the AGPLv3, see LICENCE file for details.
6
import gc "gopkg.in/check.v1"
8
type mockRunCommand struct {
10
commands []*mockCommand
13
type mockCommand struct {
20
func (m *mockCommand) respond(result string, err error) {
25
func (m *mockRunCommand) expect(cmd string, args ...string) *mockCommand {
26
command := &mockCommand{cmd: cmd, args: args}
27
m.commands = append(m.commands, command)
31
func (m *mockRunCommand) assertDrained() {
32
m.c.Assert(m.commands, gc.HasLen, 0)
35
func (m *mockRunCommand) run(cmd string, args ...string) (stdout string, err error) {
36
m.c.Assert(m.commands, gc.Not(gc.HasLen), 0)
37
expect := m.commands[0]
38
m.commands = m.commands[1:]
39
m.c.Assert(cmd, gc.Equals, expect.cmd)
40
m.c.Assert(args, gc.DeepEquals, expect.args)
41
return expect.result, expect.err