forked from 3JoB/vfs
-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexample_dummy_test.go
More file actions
40 lines (32 loc) · 781 Bytes
/
example_dummy_test.go
File metadata and controls
40 lines (32 loc) · 781 Bytes
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
package vfs_test
import (
"errors"
"fmt"
"os"
"github.com/lordofscripts/vfs"
)
type myFS struct {
vfs.Filesystem // Embed the Filesystem interface and fill it with vfs.Dummy on creation
}
func MyFS() *myFS {
return &myFS{
Filesystem: vfs.Dummy(errors.New("Not implemented yet!")),
}
}
func (fs myFS) Mkdir(name string, perm os.FileMode) error {
// Create a directory
// ...
return nil
}
func ExampleDummyFS() {
// Simply bootstrap your filesystem
var fs vfs.Filesystem = MyFS()
// Your mkdir implementation
fs.Mkdir("/tmp", 0777)
// All necessary methods like OpenFile (therefor Create) are stubbed
// and return the dummys error
_, err := vfs.Create(fs, "/tmp/vfs/example.txt")
if err != nil {
fmt.Print("Error will be: Not implemented yet!\n")
}
}