Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
N
nexpie-grafana-theme
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Registry
Registry
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Kornkitt Poolsup
nexpie-grafana-theme
Commits
2c16b0f0
Commit
2c16b0f0
authored
Feb 12, 2015
by
Torkel Ödegaard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added unit test for loading configuration file
parent
4df66684
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
29 additions
and
9 deletions
+29
-9
pkg/services/sqlstore/migrations.go
+0
-3
pkg/setting/setting.go
+7
-6
pkg/setting/setting_test.go
+22
-0
No files found.
pkg/services/sqlstore/migrations.go
View file @
2c16b0f0
...
@@ -50,9 +50,6 @@ func addUserMigrations(mg *Migrator) {
...
@@ -50,9 +50,6 @@ func addUserMigrations(mg *Migrator) {
mg
.
AddMigration
(
"Add email_verified flag"
,
new
(
AddColumnMigration
)
.
mg
.
AddMigration
(
"Add email_verified flag"
,
new
(
AddColumnMigration
)
.
Table
(
"user"
)
.
Column
(
&
Column
{
Name
:
"email_verified"
,
Type
:
DB_Bool
,
Nullable
:
true
}))
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
)
.
mg
.
AddMigration
(
"Add user.theme column"
,
new
(
AddColumnMigration
)
.
Table
(
"user"
)
.
Column
(
&
Column
{
Name
:
"theme"
,
Type
:
DB_Varchar
,
Nullable
:
true
,
Length
:
20
}))
Table
(
"user"
)
.
Column
(
&
Column
{
Name
:
"theme"
,
Type
:
DB_Varchar
,
Nullable
:
true
,
Length
:
20
}))
...
...
pkg/setting/setting.go
View file @
2c16b0f0
...
@@ -98,15 +98,10 @@ var (
...
@@ -98,15 +98,10 @@ var (
func
init
()
{
func
init
()
{
IsWindows
=
runtime
.
GOOS
==
"windows"
IsWindows
=
runtime
.
GOOS
==
"windows"
log
.
NewLogger
(
0
,
"console"
,
`{"level": 0}`
)
log
.
NewLogger
(
0
,
"console"
,
`{"level": 0}`
)
}
WorkDir
,
_
=
filepath
.
Abs
(
"."
)
func
getWorkDir
()
string
{
p
,
_
:=
filepath
.
Abs
(
"."
)
return
p
}
}
func
findConfigFiles
()
[]
string
{
func
findConfigFiles
()
[]
string
{
WorkDir
=
getWorkDir
()
ConfRootPath
=
path
.
Join
(
WorkDir
,
"conf"
)
ConfRootPath
=
path
.
Join
(
WorkDir
,
"conf"
)
filenames
:=
make
([]
string
,
0
)
filenames
:=
make
([]
string
,
0
)
...
@@ -152,6 +147,10 @@ func ToAbsUrl(relativeUrl string) string {
...
@@ -152,6 +147,10 @@ func ToAbsUrl(relativeUrl string) string {
return
AppUrl
+
relativeUrl
return
AppUrl
+
relativeUrl
}
}
func
loadEnvVariableOverrides
()
{
}
func
NewConfigContext
()
{
func
NewConfigContext
()
{
configFiles
:=
findConfigFiles
()
configFiles
:=
findConfigFiles
()
...
@@ -170,6 +169,8 @@ func NewConfigContext() {
...
@@ -170,6 +169,8 @@ func NewConfigContext() {
}
}
}
}
loadEnvVariableOverrides
()
AppName
=
Cfg
.
Section
(
""
)
.
Key
(
"app_name"
)
.
MustString
(
"Grafana"
)
AppName
=
Cfg
.
Section
(
""
)
.
Key
(
"app_name"
)
.
MustString
(
"Grafana"
)
Env
=
Cfg
.
Section
(
""
)
.
Key
(
"app_mode"
)
.
MustString
(
"development"
)
Env
=
Cfg
.
Section
(
""
)
.
Key
(
"app_mode"
)
.
MustString
(
"development"
)
...
...
pkg/setting/setting_test.go
0 → 100644
View file @
2c16b0f0
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"
)
})
})
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment