~nskaggs/+junk/xenial-test

« back to all changes in this revision

Viewing changes to src/github.com/juju/juju/service/systemd/export_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 systemd
 
5
 
 
6
import (
 
7
        "github.com/juju/testing"
 
8
)
 
9
 
 
10
var (
 
11
        Serialize       = serialize
 
12
        SyslogUserGroup = syslogUserGroup
 
13
)
 
14
 
 
15
type patcher interface {
 
16
        PatchValue(interface{}, interface{})
 
17
}
 
18
 
 
19
func PatchNewChan(patcher patcher) chan string {
 
20
        ch := make(chan string, 1)
 
21
        patcher.PatchValue(&newChan, func() chan string { return ch })
 
22
        return ch
 
23
}
 
24
 
 
25
func PatchNewConn(patcher patcher, stub *testing.Stub) *StubDbusAPI {
 
26
        conn := &StubDbusAPI{Stub: stub}
 
27
        patcher.PatchValue(&newConn, func() (dbusAPI, error) { return conn, nil })
 
28
        return conn
 
29
}
 
30
 
 
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)
 
36
        return fops
 
37
}
 
38
 
 
39
func PatchExec(patcher patcher, stub *testing.Stub) *StubExec {
 
40
        exec := &StubExec{Stub: stub}
 
41
        patcher.PatchValue(&runCommands, exec.RunCommand)
 
42
        return exec
 
43
}