mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
fix(tests): fixed failling backend test
This commit is contained in:
parent
fb9e91e486
commit
8174b9f041
6
main.go
6
main.go
@ -69,12 +69,16 @@ func main() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func initRuntime() {
|
func initRuntime() {
|
||||||
setting.NewConfigContext(&setting.CommandLineArgs{
|
err := setting.NewConfigContext(&setting.CommandLineArgs{
|
||||||
Config: *configFile,
|
Config: *configFile,
|
||||||
HomePath: *homePath,
|
HomePath: *homePath,
|
||||||
Args: flag.Args(),
|
Args: flag.Args(),
|
||||||
})
|
})
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
log.Fatal(3, err.Error())
|
||||||
|
}
|
||||||
|
|
||||||
log.Info("Starting Grafana")
|
log.Info("Starting Grafana")
|
||||||
log.Info("Version: %v, Commit: %v, Build date: %v", setting.BuildVersion, setting.BuildCommit, time.Unix(setting.BuildStamp, 0))
|
log.Info("Version: %v, Commit: %v, Build date: %v", setting.BuildVersion, setting.BuildCommit, time.Unix(setting.BuildStamp, 0))
|
||||||
setting.LogConfigurationInfo()
|
setting.LogConfigurationInfo()
|
||||||
|
@ -6,6 +6,7 @@ package setting
|
|||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"net/url"
|
"net/url"
|
||||||
"os"
|
"os"
|
||||||
@ -355,24 +356,26 @@ func setHomePath(args *CommandLineArgs) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func getStaticRootPath(configValue string) string {
|
var skipStaticRootValidation bool = false
|
||||||
if configValue != "public" {
|
|
||||||
return configValue
|
func validateStaticRootPath() error {
|
||||||
|
if skipStaticRootValidation {
|
||||||
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
if _, err := os.Stat(path.Join(HomePath, configValue, "css")); err == nil {
|
if _, err := os.Stat(path.Join(StaticRootPath, "css")); err == nil {
|
||||||
return configValue
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
if _, err := os.Stat(path.Join(HomePath, "public_gen", "css")); err == nil {
|
if _, err := os.Stat(StaticRootPath + "_gen/css"); err == nil {
|
||||||
return "public_gen"
|
StaticRootPath = StaticRootPath + "_gen"
|
||||||
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
log.Fatal(3, "Failed to detect generated css or javascript files in static root (%s), have you executed default grunt task?", configValue)
|
return errors.New("Failed to detect generated css or javascript files in static root (%s), have you executed default grunt task?")
|
||||||
return ""
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewConfigContext(args *CommandLineArgs) {
|
func NewConfigContext(args *CommandLineArgs) error {
|
||||||
setHomePath(args)
|
setHomePath(args)
|
||||||
loadConfiguration(args)
|
loadConfiguration(args)
|
||||||
|
|
||||||
@ -391,10 +394,14 @@ func NewConfigContext(args *CommandLineArgs) {
|
|||||||
Domain = server.Key("domain").MustString("localhost")
|
Domain = server.Key("domain").MustString("localhost")
|
||||||
HttpAddr = server.Key("http_addr").MustString("0.0.0.0")
|
HttpAddr = server.Key("http_addr").MustString("0.0.0.0")
|
||||||
HttpPort = server.Key("http_port").MustString("3000")
|
HttpPort = server.Key("http_port").MustString("3000")
|
||||||
StaticRootPath = makeAbsolute(getStaticRootPath(server.Key("static_root_path").String()), HomePath)
|
|
||||||
RouterLogging = server.Key("router_logging").MustBool(false)
|
RouterLogging = server.Key("router_logging").MustBool(false)
|
||||||
EnableGzip = server.Key("enable_gzip").MustBool(false)
|
EnableGzip = server.Key("enable_gzip").MustBool(false)
|
||||||
EnforceDomain = server.Key("enforce_domain").MustBool(false)
|
EnforceDomain = server.Key("enforce_domain").MustBool(false)
|
||||||
|
StaticRootPath = makeAbsolute(server.Key("static_root_path").String(), HomePath)
|
||||||
|
|
||||||
|
if err := validateStaticRootPath(); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
// read security settings
|
// read security settings
|
||||||
security := Cfg.Section("security")
|
security := Cfg.Section("security")
|
||||||
@ -455,6 +462,8 @@ func NewConfigContext(args *CommandLineArgs) {
|
|||||||
if VerifyEmailEnabled && !Smtp.Enabled {
|
if VerifyEmailEnabled && !Smtp.Enabled {
|
||||||
log.Warn("require_email_validation is enabled but smpt is disabled")
|
log.Warn("require_email_validation is enabled but smpt is disabled")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func readSessionConfig() {
|
func readSessionConfig() {
|
||||||
|
@ -11,9 +11,11 @@ import (
|
|||||||
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() {
|
||||||
|
skipStaticRootValidation = true
|
||||||
|
|
||||||
Convey("Given the default ini files", func() {
|
Convey("Given the default ini files", func() {
|
||||||
NewConfigContext(&CommandLineArgs{HomePath: "../../"})
|
err := NewConfigContext(&CommandLineArgs{HomePath: "../../"})
|
||||||
|
So(err, ShouldBeNil)
|
||||||
|
|
||||||
So(AdminUser, ShouldEqual, "admin")
|
So(AdminUser, ShouldEqual, "admin")
|
||||||
})
|
})
|
||||||
|
@ -1,10 +1,8 @@
|
|||||||
///<reference path="../headers/require/require.d.ts" />
|
///<reference path="../headers/common.d.ts" />
|
||||||
///<reference path="../headers/angularjs/angularjs.d.ts" />
|
///<amd-dependency path="config" name="config" />
|
||||||
///<amd-dependency path="angular"/>
|
|
||||||
///<amd-dependency path="config"/>
|
|
||||||
|
|
||||||
var angular = require('angular');
|
import angular = require('angular');
|
||||||
var config = require('config');
|
declare var config : any;
|
||||||
|
|
||||||
var module = angular.module('grafana.controllers');
|
var module = angular.module('grafana.controllers');
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
///<reference path="../../headers/common.d.ts" />
|
///<reference path="../../headers/common.d.ts" />
|
||||||
//
|
|
||||||
import angular = require('angular');
|
import angular = require('angular');
|
||||||
import jquery = require('jquery');
|
import jquery = require('jquery');
|
||||||
import moment = require('moment');
|
import moment = require('moment');
|
||||||
|
Loading…
Reference in New Issue
Block a user