...
1
2
3
4
5
6
7
8
9
10
11
12
13 package filesystem
14
15 import "os"
16
17
18 type MockFS struct {
19 MkdirFunc func(string, os.FileMode) error
20 MkdirAllFunc func(string, os.FileMode) error
21 CreateFunc func(string) (File, error)
22 OpenFunc func(string) (File, error)
23 StatFunc func(string) (os.FileInfo, error)
24 TempFileFunc func(string, string) (File, error)
25 RenameFunc func(string, string) error
26 RemoveFunc func(string) error
27 LinkFunc func(string, string) error
28 }
29
30 var _ Filesystem = &MockFS{}
31
32
33 func (fs *MockFS) Mkdir(name string, perm os.FileMode) error {
34 return fs.MkdirFunc(name, perm)
35 }
36
37
38 func (fs *MockFS) MkdirAll(path string, perm os.FileMode) error {
39 return fs.MkdirAllFunc(path, perm)
40 }
41
42
43 func (fs *MockFS) Open(name string) (File, error) {
44 return fs.OpenFunc(name)
45 }
46
47
48 func (fs *MockFS) Create(name string) (File, error) {
49 return fs.CreateFunc(name)
50 }
51
52
53 func (fs *MockFS) Stat(name string) (os.FileInfo, error) {
54 return fs.StatFunc(name)
55 }
56
57
58 func (fs *MockFS) TempFile(dir, pattern string) (File, error) {
59 return fs.TempFileFunc(dir, pattern)
60 }
61
62
63 func (fs *MockFS) Rename(oldpath, newpath string) error {
64 return fs.RenameFunc(oldpath, newpath)
65 }
66
67
68 func (fs *MockFS) Remove(name string) error {
69 return fs.RemoveFunc(name)
70 }
71
72
73 func (fs *MockFS) Link(oldname, newname string) error {
74 return fs.LinkFunc(oldname, newname)
75 }
76
View as plain text