-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfilesystem_test.go
54 lines (42 loc) · 898 Bytes
/
filesystem_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
package medialocker
import (
"testing"
"github.com/casimir/xdg-go"
"github.com/spf13/afero"
)
func init() {
testFileSystem = FileSystem{App: xdg.App{Name: "medialocker"}, Fs: afero.NewMemMapFs()}
}
func GetTestFileSystem() FileSystem {
return testFileSystem
}
func ResetTestFileSystem() FileSystem {
testFileSystem = FileSystem{App: xdg.App{Name: "medialocker"}, Fs: afero.NewMemMapFs()}
return testFileSystem
}
func EnableTestFileSystem() {
testFsMode = true
}
func DisableTestFileSystem() {
testFsMode = false
}
func TestFileSystem(t *testing.T) {
fs := GetTestFileSystem()
if fs != testFileSystem {
t.Error("GetTestFileSystem returned nil, expected test filesystem.")
}
}
func TestMain(m *testing.M) {
setup()
ret := m.Run()
if ret == 0 {
teardown()
}
}
func setup() {
EnableTestFileSystem()
ResetTestFileSystem()
}
func teardown() {
DisableTestFileSystem()
}