Commit 2c16b0f0 by Torkel Ödegaard

added unit test for loading configuration file

parent 4df66684
......@@ -50,9 +50,6 @@ func addUserMigrations(mg *Migrator) {
mg.AddMigration("Add email_verified flag", new(AddColumnMigration).
Table("user").Column(&Column{Name: "email_verified", Type: DB_Bool, Nullable: true}))
mg.AddMigration("Add email_verified flag", new(AddColumnMigration).
Table("user").Column(&Column{Name: "email_verified", Type: DB_Bool, Nullable: true}))
mg.AddMigration("Add user.theme column", new(AddColumnMigration).
Table("user").Column(&Column{Name: "theme", Type: DB_Varchar, Nullable: true, Length: 20}))
......
......@@ -98,15 +98,10 @@ var (
func init() {
IsWindows = runtime.GOOS == "windows"
log.NewLogger(0, "console", `{"level": 0}`)
}
func getWorkDir() string {
p, _ := filepath.Abs(".")
return p
WorkDir, _ = filepath.Abs(".")
}
func findConfigFiles() []string {
WorkDir = getWorkDir()
ConfRootPath = path.Join(WorkDir, "conf")
filenames := make([]string, 0)
......@@ -152,6 +147,10 @@ func ToAbsUrl(relativeUrl string) string {
return AppUrl + relativeUrl
}
func loadEnvVariableOverrides() {
}
func NewConfigContext() {
configFiles := findConfigFiles()
......@@ -170,6 +169,8 @@ func NewConfigContext() {
}
}
loadEnvVariableOverrides()
AppName = Cfg.Section("").Key("app_name").MustString("Grafana")
Env = Cfg.Section("").Key("app_mode").MustString("development")
......
package setting
import (
"path/filepath"
"testing"
. "github.com/smartystreets/goconvey/convey"
)
func TestLoadingSettings(t *testing.T) {
WorkDir, _ = filepath.Abs("../../")
Convey("Testing loading settings from ini file", t, func() {
Convey("Given the default ini files", func() {
NewConfigContext()
So(AppName, ShouldEqual, "Grafana")
})
})
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment