forked from grafana/grafana
-
Notifications
You must be signed in to change notification settings - Fork 0
/
fake_ioutil.go
55 lines (42 loc) · 938 Bytes
/
fake_ioutil.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
package commandstest
import (
"os"
"time"
)
type FakeIoUtil struct {
FakeReadDir []os.FileInfo
FakeIsDirectory bool
}
func (util *FakeIoUtil) Stat(path string) (os.FileInfo, error) {
return &FakeFileInfo{IsDirectory: util.FakeIsDirectory}, nil
}
func (util *FakeIoUtil) RemoveAll(path string) error {
return nil
}
func (util *FakeIoUtil) ReadDir(path string) ([]os.FileInfo, error) {
return util.FakeReadDir, nil
}
func (i *FakeIoUtil) ReadFile(filename string) ([]byte, error) {
return make([]byte, 0), nil
}
type FakeFileInfo struct {
IsDirectory bool
}
func (ffi *FakeFileInfo) IsDir() bool {
return ffi.IsDirectory
}
func (ffi FakeFileInfo) Size() int64 {
return 1
}
func (ffi FakeFileInfo) Mode() os.FileMode {
return 0777
}
func (ffi FakeFileInfo) Name() string {
return ""
}
func (ffi FakeFileInfo) ModTime() time.Time {
return time.Time{}
}
func (ffi FakeFileInfo) Sys() interface{} {
return nil
}