This repository has been archived by the owner on Apr 25, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
os_mock.go
103 lines (90 loc) · 2.46 KB
/
os_mock.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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
package examples
// Don't edit this file.
// This file is generated by gomic 0.4.0.
// https://github.com/suzuki-shunsuke/gomic
import (
"os"
testing "testing"
gomic "github.com/suzuki-shunsuke/gomic/gomic"
)
type (
// OSMock is a mock.
OSMock struct {
t *testing.T
name string
callbackNotImplemented gomic.CallbackNotImplemented
impl struct {
Getwd func() (string, error)
Mkdir func(name string, perm os.FileMode) error
}
}
)
// NewOSMock returns OSMock .
func NewOSMock(t *testing.T, cb gomic.CallbackNotImplemented) *OSMock {
return &OSMock{t: t, callbackNotImplemented: cb}
}
// Getwd is a mock method.
func (mock OSMock) Getwd() (string, error) {
methodName := "Getwd" // nolint: goconst
if mock.impl.Getwd != nil {
return mock.impl.Getwd()
}
if mock.callbackNotImplemented != nil {
mock.callbackNotImplemented(mock.t, mock.name, methodName)
} else {
gomic.DefaultCallbackNotImplemented(mock.t, mock.name, methodName)
}
return mock.fakeZeroGetwd()
}
// SetFuncGetwd sets a method and returns the mock.
func (mock *OSMock) SetFuncGetwd(impl func() (string, error)) *OSMock {
mock.impl.Getwd = impl
return mock
}
// SetReturnGetwd sets a fake method.
func (mock *OSMock) SetReturnGetwd(r0 string, r1 error) *OSMock {
mock.impl.Getwd = func() (string, error) {
return r0, r1
}
return mock
}
// fakeZeroGetwd is a fake method which returns zero values.
func (mock OSMock) fakeZeroGetwd() (string, error) {
var (
r0 string
r1 error
)
return r0, r1
}
// Mkdir is a mock method.
func (mock OSMock) Mkdir(name string, perm os.FileMode) error {
methodName := "Mkdir" // nolint: goconst
if mock.impl.Mkdir != nil {
return mock.impl.Mkdir(name, perm)
}
if mock.callbackNotImplemented != nil {
mock.callbackNotImplemented(mock.t, mock.name, methodName)
} else {
gomic.DefaultCallbackNotImplemented(mock.t, mock.name, methodName)
}
return mock.fakeZeroMkdir(name, perm)
}
// SetFuncMkdir sets a method and returns the mock.
func (mock *OSMock) SetFuncMkdir(impl func(name string, perm os.FileMode) error) *OSMock {
mock.impl.Mkdir = impl
return mock
}
// SetReturnMkdir sets a fake method.
func (mock *OSMock) SetReturnMkdir(r0 error) *OSMock {
mock.impl.Mkdir = func(string, os.FileMode) error {
return r0
}
return mock
}
// fakeZeroMkdir is a fake method which returns zero values.
func (mock OSMock) fakeZeroMkdir(name string, perm os.FileMode) error {
var (
r0 error
)
return r0
}