|
@@ -1,10 +1,12 @@
|
|
|
package setting
|
|
package setting
|
|
|
|
|
|
|
|
import (
|
|
import (
|
|
|
|
|
+ "bufio"
|
|
|
"os"
|
|
"os"
|
|
|
"path"
|
|
"path"
|
|
|
"path/filepath"
|
|
"path/filepath"
|
|
|
"runtime"
|
|
"runtime"
|
|
|
|
|
+ "strings"
|
|
|
"testing"
|
|
"testing"
|
|
|
|
|
|
|
|
"gopkg.in/ini.v1"
|
|
"gopkg.in/ini.v1"
|
|
@@ -30,6 +32,22 @@ func TestLoadingSettings(t *testing.T) {
|
|
|
So(cfg.RendererCallbackUrl, ShouldEqual, "http://localhost:3000/")
|
|
So(cfg.RendererCallbackUrl, ShouldEqual, "http://localhost:3000/")
|
|
|
})
|
|
})
|
|
|
|
|
|
|
|
|
|
+ Convey("default.ini should have no semi-colon commented entries", func() {
|
|
|
|
|
+ file, err := os.Open("../../conf/defaults.ini")
|
|
|
|
|
+ if err != nil {
|
|
|
|
|
+ t.Errorf("failed to load defaults.ini file: %v", err)
|
|
|
|
|
+ }
|
|
|
|
|
+ defer file.Close()
|
|
|
|
|
+
|
|
|
|
|
+ scanner := bufio.NewScanner(file)
|
|
|
|
|
+ for scanner.Scan() {
|
|
|
|
|
+ // This only catches values commented out with ";" and will not catch those that are commented out with "#".
|
|
|
|
|
+ if strings.HasPrefix(scanner.Text(), ";") {
|
|
|
|
|
+ t.Errorf("entries in defaults.ini must not be commented or environment variables will not work: %v", scanner.Text())
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ })
|
|
|
|
|
+
|
|
|
Convey("Should be able to override via environment variables", func() {
|
|
Convey("Should be able to override via environment variables", func() {
|
|
|
os.Setenv("GF_SECURITY_ADMIN_USER", "superduper")
|
|
os.Setenv("GF_SECURITY_ADMIN_USER", "superduper")
|
|
|
|
|
|