-
Notifications
You must be signed in to change notification settings - Fork 1
/
dummy_test.go
66 lines (60 loc) · 1.69 KB
/
dummy_test.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
package vfs
import (
"errors"
"testing"
)
var errDum = errors.New("Dummy error")
func TestInterface(t *testing.T) {
_ = Filesystem(Dummy(errDum))
}
func TestDummyFS(t *testing.T) {
fs := Dummy(errDum)
if _, err := fs.Open("/tmp/test123"); err != errDum {
t.Errorf("Open DummyError expected: %s", err)
}
if _, err := fs.OpenFile("test", 0, 0); err != errDum {
t.Errorf("OpenFile DummyError expected: %s", err)
}
if err := fs.Remove("test"); err != errDum {
t.Errorf("Remove DummyError expected: %s", err)
}
if err := fs.Rename("old", "new"); err != errDum {
t.Errorf("Rename DummyError expected: %s", err)
}
if err := fs.Mkdir("test", 0); err != errDum {
t.Errorf("Mkdir DummyError expected: %s", err)
}
if _, err := fs.Stat("test"); err != errDum {
t.Errorf("Stat DummyError expected: %s", err)
}
if _, err := fs.Lstat("test"); err != errDum {
t.Errorf("Lstat DummyError expected: %s", err)
}
if _, err := fs.ReadDir("test"); err != errDum {
t.Errorf("ReadDir DummyError expected: %s", err)
}
}
func TestFileInterface(t *testing.T) {
_ = File(DummyFile(errDum))
}
func TestDummyFile(t *testing.T) {
f := DummyFile(errDum)
if name := f.Name(); name != "dummy" {
t.Errorf("Invalid name: %s", name)
}
if err := f.Close(); err != errDum {
t.Errorf("Close DummyError expected: %s", err)
}
if _, err := f.Write([]byte("test")); err != errDum {
t.Errorf("Write DummyError expected: %s", err)
}
if _, err := f.Read([]byte{}); err != errDum {
t.Errorf("Read DummyError expected: %s", err)
}
if _, err := f.Seek(0, 0); err != errDum {
t.Errorf("Seek DummyError expected: %s", err)
}
if err := f.Sync(); err != errDum {
t.Errorf("Sync DummyError expected: %s", err)
}
}