summaryrefslogtreecommitdiff
path: root/settings/settings_test.go
diff options
context:
space:
mode:
authorAidan Nulman <[email protected]>2014-04-03 16:41:43 -0400
committerAidan Nulman <[email protected]>2014-04-03 16:41:43 -0400
commitd9f4adff6c548a6cb6f00258c99129c7e41062b3 (patch)
tree264a73dcf05f99cec7395b20b3488ea202c3cadf /settings/settings_test.go
parentb5e60dc106828b308fdb7e69fe10a0d2dec4eece (diff)
parent9cd1d129bcd567ef65137783a603f8d898d8d933 (diff)
Merge branch 'master' into custom_odb
Conflicts: odb.go wrapper.c
Diffstat (limited to 'settings/settings_test.go')
-rw-r--r--settings/settings_test.go66
1 files changed, 66 insertions, 0 deletions
diff --git a/settings/settings_test.go b/settings/settings_test.go
new file mode 100644
index 0000000..55b08c8
--- /dev/null
+++ b/settings/settings_test.go
@@ -0,0 +1,66 @@
+package settings
+
+import (
+ "testing"
+ "runtime"
+ "github.com/libgit2/git2go"
+)
+
+type pathPair struct {
+ Level git.ConfigLevel
+ Path string
+}
+
+func TestSearchPath(t *testing.T) {
+ paths := []pathPair{
+ pathPair{git.ConfigLevelSystem, "/tmp/system"},
+ pathPair{git.ConfigLevelGlobal, "/tmp/global"},
+ pathPair{git.ConfigLevelXDG, "/tmp/xdg"},
+ }
+
+ for _, pair := range paths {
+ err := SetSearchPath(pair.Level, pair.Path)
+ checkFatal(t, err)
+
+ actual, err := SearchPath(pair.Level)
+ checkFatal(t, err)
+
+ if pair.Path != actual {
+ t.Fatal("Search paths don't match")
+ }
+ }
+}
+
+func TestMmapSizes(t *testing.T) {
+ size := 42 * 1024
+
+ err := SetMwindowSize(size)
+ checkFatal(t, err)
+
+ actual, err := MwindowSize()
+ if size != actual {
+ t.Fatal("Sizes don't match")
+ }
+
+ err = SetMwindowMappedLimit(size)
+ checkFatal(t, err)
+
+ actual, err = MwindowMappedLimit()
+ if size != actual {
+ t.Fatal("Sizes don't match")
+ }
+}
+
+func checkFatal(t *testing.T, err error) {
+ if err == nil {
+ return
+ }
+
+ // The failure happens at wherever we were called, not here
+ _, file, line, ok := runtime.Caller(1)
+ if !ok {
+ t.Fatal()
+ }
+
+ t.Fatalf("Fail at %v:%v; %v", file, line, err)
+}