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
8921b0b5
Commit
8921b0b5
authored
Feb 08, 2018
by
Marcus Efraimsson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
db test: allow use of env variable for database engine to run tests for
parent
a91bd53a
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
28 additions
and
3 deletions
+28
-3
pkg/services/sqlstore/datasource_test.go
+28
-3
No files found.
pkg/services/sqlstore/datasource_test.go
View file @
8921b0b5
package
sqlstore
import
(
"os"
"strings"
"testing"
"github.com/go-xorm/xorm"
...
...
@@ -11,10 +13,33 @@ import (
"github.com/grafana/grafana/pkg/services/sqlstore/sqlutil"
)
var
(
dbSqlite
=
"sqlite"
dbMySql
=
"mysql"
dbPostgres
=
"postgres"
)
func
InitTestDB
(
t
*
testing
.
T
)
*
xorm
.
Engine
{
x
,
err
:=
xorm
.
NewEngine
(
sqlutil
.
TestDB_Sqlite3
.
DriverName
,
sqlutil
.
TestDB_Sqlite3
.
ConnStr
)
//x, err := xorm.NewEngine(sqlutil.TestDB_Mysql.DriverName, sqlutil.TestDB_Mysql.ConnStr)
//x, err := xorm.NewEngine(sqlutil.TestDB_Postgres.DriverName, sqlutil.TestDB_Postgres.ConnStr)
selectedDb
:=
dbSqlite
//selectedDb := dbMySql
//selectedDb := dbPostgres
var
x
*
xorm
.
Engine
var
err
error
// environment variable present for test db?
if
db
,
present
:=
os
.
LookupEnv
(
"GRAFANA_TEST_DB"
);
present
{
selectedDb
=
db
}
switch
strings
.
ToLower
(
selectedDb
)
{
case
dbMySql
:
x
,
err
=
xorm
.
NewEngine
(
sqlutil
.
TestDB_Mysql
.
DriverName
,
sqlutil
.
TestDB_Mysql
.
ConnStr
)
case
dbPostgres
:
x
,
err
=
xorm
.
NewEngine
(
sqlutil
.
TestDB_Postgres
.
DriverName
,
sqlutil
.
TestDB_Postgres
.
ConnStr
)
default
:
x
,
err
=
xorm
.
NewEngine
(
sqlutil
.
TestDB_Sqlite3
.
DriverName
,
sqlutil
.
TestDB_Sqlite3
.
ConnStr
)
}
// x.ShowSQL()
...
...
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