|
@@ -1,16 +1,21 @@
|
|
|
package setting
|
|
package setting
|
|
|
|
|
|
|
|
import (
|
|
import (
|
|
|
- "gopkg.in/ini.v1"
|
|
|
|
|
"os"
|
|
"os"
|
|
|
"path"
|
|
"path"
|
|
|
"path/filepath"
|
|
"path/filepath"
|
|
|
"runtime"
|
|
"runtime"
|
|
|
"testing"
|
|
"testing"
|
|
|
|
|
|
|
|
|
|
+ "gopkg.in/ini.v1"
|
|
|
|
|
+
|
|
|
. "github.com/smartystreets/goconvey/convey"
|
|
. "github.com/smartystreets/goconvey/convey"
|
|
|
)
|
|
)
|
|
|
|
|
|
|
|
|
|
+const (
|
|
|
|
|
+ windows = "windows"
|
|
|
|
|
+)
|
|
|
|
|
+
|
|
|
func TestLoadingSettings(t *testing.T) {
|
|
func TestLoadingSettings(t *testing.T) {
|
|
|
|
|
|
|
|
Convey("Testing loading settings from ini file", t, func() {
|
|
Convey("Testing loading settings from ini file", t, func() {
|
|
@@ -72,7 +77,7 @@ func TestLoadingSettings(t *testing.T) {
|
|
|
})
|
|
})
|
|
|
|
|
|
|
|
Convey("Should be able to override via command line", func() {
|
|
Convey("Should be able to override via command line", func() {
|
|
|
- if runtime.GOOS == "windows" {
|
|
|
|
|
|
|
+ if runtime.GOOS == windows {
|
|
|
cfg := NewCfg()
|
|
cfg := NewCfg()
|
|
|
cfg.Load(&CommandLineArgs{
|
|
cfg.Load(&CommandLineArgs{
|
|
|
HomePath: "../../",
|
|
HomePath: "../../",
|
|
@@ -106,7 +111,7 @@ func TestLoadingSettings(t *testing.T) {
|
|
|
})
|
|
})
|
|
|
|
|
|
|
|
Convey("Defaults can be overridden in specified config file", func() {
|
|
Convey("Defaults can be overridden in specified config file", func() {
|
|
|
- if runtime.GOOS == "windows" {
|
|
|
|
|
|
|
+ if runtime.GOOS == windows {
|
|
|
cfg := NewCfg()
|
|
cfg := NewCfg()
|
|
|
cfg.Load(&CommandLineArgs{
|
|
cfg.Load(&CommandLineArgs{
|
|
|
HomePath: "../../",
|
|
HomePath: "../../",
|
|
@@ -128,7 +133,7 @@ func TestLoadingSettings(t *testing.T) {
|
|
|
})
|
|
})
|
|
|
|
|
|
|
|
Convey("Command line overrides specified config file", func() {
|
|
Convey("Command line overrides specified config file", func() {
|
|
|
- if runtime.GOOS == "windows" {
|
|
|
|
|
|
|
+ if runtime.GOOS == windows {
|
|
|
cfg := NewCfg()
|
|
cfg := NewCfg()
|
|
|
cfg.Load(&CommandLineArgs{
|
|
cfg.Load(&CommandLineArgs{
|
|
|
HomePath: "../../",
|
|
HomePath: "../../",
|
|
@@ -150,7 +155,7 @@ func TestLoadingSettings(t *testing.T) {
|
|
|
})
|
|
})
|
|
|
|
|
|
|
|
Convey("Can use environment variables in config values", func() {
|
|
Convey("Can use environment variables in config values", func() {
|
|
|
- if runtime.GOOS == "windows" {
|
|
|
|
|
|
|
+ if runtime.GOOS == windows {
|
|
|
os.Setenv("GF_DATA_PATH", `c:\tmp\env_override`)
|
|
os.Setenv("GF_DATA_PATH", `c:\tmp\env_override`)
|
|
|
cfg := NewCfg()
|
|
cfg := NewCfg()
|
|
|
cfg.Load(&CommandLineArgs{
|
|
cfg.Load(&CommandLineArgs{
|