1
// Copyright 2015 Canonical Ltd.
2
// Licensed under the AGPLv3, see LICENCE file for details.
7
"github.com/juju/testing"
12
SyslogUserGroup = syslogUserGroup
15
type patcher interface {
16
PatchValue(interface{}, interface{})
19
func PatchNewChan(patcher patcher) chan string {
20
ch := make(chan string, 1)
21
patcher.PatchValue(&newChan, func() chan string { return ch })
25
func PatchNewConn(patcher patcher, stub *testing.Stub) *StubDbusAPI {
26
conn := &StubDbusAPI{Stub: stub}
27
patcher.PatchValue(&newConn, func() (dbusAPI, error) { return conn, nil })
31
func PatchFileOps(patcher patcher, stub *testing.Stub) *StubFileOps {
32
fops := &StubFileOps{Stub: stub}
33
patcher.PatchValue(&removeAll, fops.RemoveAll)
34
patcher.PatchValue(&mkdirAll, fops.MkdirAll)
35
patcher.PatchValue(&createFile, fops.CreateFile)
39
func PatchExec(patcher patcher, stub *testing.Stub) *StubExec {
40
exec := &StubExec{Stub: stub}
41
patcher.PatchValue(&runCommands, exec.RunCommand)