- Notifications
You must be signed in to change notification settings - Fork 324
/
Copy pathsettings_test.go
99 lines (76 loc) · 1.73 KB
/
settings_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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
package git
import (
"testing"
)
typepathPairstruct {
LevelConfigLevel
Pathstring
}
funcTestSearchPath(t*testing.T) {
paths:= []pathPair{
pathPair{ConfigLevelSystem, "/tmp/system"},
pathPair{ConfigLevelGlobal, "/tmp/global"},
pathPair{ConfigLevelXDG, "/tmp/xdg"},
}
for_, pair:=rangepaths {
err:=SetSearchPath(pair.Level, pair.Path)
checkFatal(t, err)
actual, err:=SearchPath(pair.Level)
checkFatal(t, err)
ifpair.Path!=actual {
t.Fatal("Search paths don't match")
}
}
}
funcTestMmapSizes(t*testing.T) {
size:=42*1024
err:=SetMwindowSize(size)
checkFatal(t, err)
actual, err:=MwindowSize()
ifsize!=actual {
t.Fatal("Sizes don't match")
}
err=SetMwindowMappedLimit(size)
checkFatal(t, err)
actual, err=MwindowMappedLimit()
ifsize!=actual {
t.Fatal("Sizes don't match")
}
}
funcTestEnableCaching(t*testing.T) {
err:=EnableCaching(false)
checkFatal(t, err)
err=EnableCaching(true)
checkFatal(t, err)
}
funcTestEnableStrictHashVerification(t*testing.T) {
err:=EnableStrictHashVerification(false)
checkFatal(t, err)
err=EnableStrictHashVerification(true)
checkFatal(t, err)
}
funcTestEnableFsyncGitDir(t*testing.T) {
err:=EnableFsyncGitDir(false)
checkFatal(t, err)
err=EnableFsyncGitDir(true)
checkFatal(t, err)
}
funcTestCachedMemory(t*testing.T) {
current, allowed, err:=CachedMemory()
checkFatal(t, err)
ifcurrent<0 {
t.Fatal("current < 0")
}
ifallowed<0 {
t.Fatal("allowed < 0")
}
}
funcTestSetCacheMaxSize(t*testing.T) {
err:=SetCacheMaxSize(0)
checkFatal(t, err)
err=SetCacheMaxSize(1024*1024)
checkFatal(t, err)
// revert to default 256MB
err=SetCacheMaxSize(256*1024*1024)
checkFatal(t, err)
}