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
dc002abe
Commit
dc002abe
authored
Oct 24, 2017
by
bergquist
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
datasource as cfg: test for reading all properties
parent
5d49846e
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
76 additions
and
32 deletions
+76
-32
conf/datasources.yaml
+32
-32
pkg/services/provisioning/datasources/datasources_test.go
+27
-0
pkg/services/provisioning/datasources/test-configs/all-properties.yaml
+17
-0
No files found.
conf/datasources.yaml
View file @
dc002abe
...
...
@@ -6,36 +6,36 @@ purge_other_datasources: false
# list of datasources to insert/update depending
# whats available in the datbase
datasources
:
# <string, required> name of the datasource. Required
-
name
:
Graphite
# <string, required> datasource type. Required
type
:
graphite
# <string, required> access mode. direct or proxy. Required
access
:
proxy
# <string, required> url
url
:
http://localhost:8080
# <string> database password, if used
password
:
# <string> database user, if used
user
:
# <string> database name, if used
database
:
# <bool> enable/disable basic auth
basic_auth
:
# <string> basic auth username
basic_authU
ser
:
# <string> basic auth password
basic_auth_password
:
# <bool> enable/disable with credentials headers
with_credentials
:
# <bool> mark as default datasource. Max one per org
is_default
:
# <string> json data
json_data
:
'
{"graphiteVersion":"0.9"}'
# <string> json object of data that will be encrypted in UI.
secure_json_fields
:
'
'
-
name
:
Prometheus
type
:
prometheus
access
:
proxy
url
:
http://localhost:9090
#
# <string, required> name of the datasource. Required
#
- name: Graphite
#
# <string, required> datasource type. Required
#
type: graphite
#
# <string, required> access mode. direct or proxy. Required
#
access: proxy
#
# <string, required> url
#
url: http://localhost:8080
#
# <string> database password, if used
#
password:
#
# <string> database user, if used
#
user:
#
# <string> database name, if used
#
database:
#
# <bool> enable/disable basic auth
#
basic_auth:
#
# <string> basic auth username
# basic_auth_u
ser:
#
# <string> basic auth password
#
basic_auth_password:
#
# <bool> enable/disable with credentials headers
#
with_credentials:
#
# <bool> mark as default datasource. Max one per org
#
is_default:
#
# <string> json data
#
json_data: '{"graphiteVersion":"0.9"}'
#
# <string> json object of data that will be encrypted in UI.
#
secure_json_fields: ''
#
- name: Prometheus
#
type: prometheus
#
access: proxy
#
url: http://localhost:9090
pkg/services/provisioning/datasources/datasources_test.go
View file @
dc002abe
...
...
@@ -15,6 +15,7 @@ var (
twoDatasourcesConfig
string
=
"./test-configs/two-datasources.yaml"
twoDatasourcesConfigPurgeOthers
string
=
"./test-configs/two-datasources-purge-others.yaml"
doubleDatasourcesConfig
string
=
"./test-configs/double-default-datasources.yaml"
allProperties
string
=
"./test-configs/all-properties.yaml"
)
func
TestDatasourceAsConfig
(
t
*
testing
.
T
)
{
...
...
@@ -102,6 +103,32 @@ func TestDatasourceAsConfig(t *testing.T) {
})
})
})
Convey
(
"can read all properties"
,
func
()
{
cfgProvifer
:=
configProvider
{}
cfg
,
err
:=
cfgProvifer
.
readConfig
(
allProperties
)
if
err
!=
nil
{
t
.
Fatalf
(
"readConfig return an error %v"
,
err
)
}
So
(
cfg
.
PurgeOtherDatasources
,
ShouldBeTrue
)
ds
:=
cfg
.
Datasources
[
0
]
So
(
ds
.
Name
,
ShouldEqual
,
"name"
)
So
(
ds
.
Type
,
ShouldEqual
,
"type"
)
So
(
ds
.
Access
,
ShouldEqual
,
models
.
DS_ACCESS_PROXY
)
So
(
ds
.
OrgId
,
ShouldEqual
,
2
)
So
(
ds
.
Url
,
ShouldEqual
,
"url"
)
So
(
ds
.
User
,
ShouldEqual
,
"user"
)
So
(
ds
.
Password
,
ShouldEqual
,
"password"
)
So
(
ds
.
Database
,
ShouldEqual
,
"database"
)
So
(
ds
.
BasicAuth
,
ShouldBeTrue
)
So
(
ds
.
BasicAuthUser
,
ShouldEqual
,
"basic_auth_user"
)
So
(
ds
.
BasicAuthPassword
,
ShouldEqual
,
"basic_auth_password"
)
So
(
ds
.
WithCredentials
,
ShouldBeTrue
)
So
(
ds
.
IsDefault
,
ShouldBeTrue
)
})
})
}
...
...
pkg/services/provisioning/datasources/test-configs/all-properties.yaml
0 → 100644
View file @
dc002abe
purge_other_datasources
:
true
datasources
:
-
name
:
name
type
:
type
access
:
proxy
org_id
:
2
url
:
url
password
:
password
user
:
user
database
:
database
basic_auth
:
true
basic_auth_user
:
basic_auth_user
basic_auth_password
:
basic_auth_password
with_credentials
:
true
is_default
:
true
json_data
:
'
{"graphiteVersion":"0.9"}'
secure_json_fields
:
'
'
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