-
Notifications
You must be signed in to change notification settings - Fork 1
/
test_helpers.go
50 lines (40 loc) · 945 Bytes
/
test_helpers.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
package vagrant_go
import (
"github.com/stretchr/testify/mock"
"testing"
)
func emptyCommandRunFunc(cmd string, args ...string) ([]byte, error) {
return []byte{}, nil
}
func emptyLookPathFunc(file string) (string, error) {
return "", nil
}
func testClient(
t *testing.T,
commandRunFunc func(cmd string, args ...string) ([]byte, error),
lookPathFunc func(file string) (string, error),
) *Client {
client, err := NewClient(nil, commandRunFunc, lookPathFunc)
if err != nil {
t.Fatal(err)
}
return client
}
func emptyTestClient(t *testing.T) *Client {
client, err := NewClient(nil, emptyCommandRunFunc, emptyLookPathFunc)
if err != nil {
t.Fatal(err)
}
return client
}
type fakeOsExecutor struct {
mock.Mock
}
func (f *fakeOsExecutor) Getwd() (string, error) {
args := f.Called()
return args.String(0), args.Error(1)
}
func (f *fakeOsExecutor) Chdir(dir string) error {
args := f.Called(dir)
return args.Error(0)
}