1
0
mirror of https://github.com/aclindsa/moneygo.git synced 2025-06-23 17:08:37 -04:00

Add first test

This tests only querying security templates, and not very exhaustively,
but it's a test!
This commit is contained in:
2017-10-05 08:06:08 -04:00
parent ad0d9bf4af
commit e0ce1576cd
4 changed files with 102 additions and 7 deletions

@ -11,19 +11,19 @@ import (
"gopkg.in/gorp.v1"
)
func GetDbMap(db *sql.DB, cfg *config.Config) (*gorp.DbMap, error) {
func GetDbMap(db *sql.DB, dbtype config.DbType) (*gorp.DbMap, error) {
var dialect gorp.Dialect
if cfg.MoneyGo.DBType == config.SQLite {
if dbtype == config.SQLite {
dialect = gorp.SqliteDialect{}
} else if cfg.MoneyGo.DBType == config.MySQL {
} else if dbtype == config.MySQL {
dialect = gorp.MySQLDialect{
Engine: "InnoDB",
Encoding: "UTF8",
}
} else if cfg.MoneyGo.DBType == config.Postgres {
} else if dbtype == config.Postgres {
dialect = gorp.PostgresDialect{}
} else {
return nil, fmt.Errorf("Don't know gorp dialect to go with '%s' DB type", cfg.MoneyGo.DBType.String())
return nil, fmt.Errorf("Don't know gorp dialect to go with '%s' DB type", dbtype.String())
}
dbmap := &gorp.DbMap{Db: db, Dialect: dialect}