Add test for loadGlobal().
authorOllivier Robert <roberto@keltia.net>
Mon, 10 Apr 2017 19:36:10 +0200
changeset 45 c1fd96210492
parent 44 f676c2646270
child 46 d25fab59ded9
Add test for loadGlobal().
config_test.go
--- a/config_test.go	Mon Apr 10 19:35:54 2017 +0200
+++ b/config_test.go	Mon Apr 10 19:36:10 2017 +0200
@@ -1,2 +1,22 @@
 package gondole
 
+import (
+	"testing"
+	"github.com/stretchr/testify/assert"
+	"path/filepath"
+)
+
+func TestLoadGlobal(t *testing.T) {
+	baseDir = "."
+
+	_, err := loadGlobal(filepath.Join("test", "non.toml"))
+	assert.Error(t, err, "does not exist")
+
+	_, err = loadGlobal(filepath.Join("test", "perms.toml"))
+	assert.Error(t, err, "unreadable")
+
+	c, err := loadGlobal(filepath.Join("test", "config.toml"))
+	assert.NoError(t, err, "should read it fine")
+	assert.EqualValues(t, "foobar", c.Default, "equal")
+}
+